PHP code example of bahaaalhagar / shoppingcart

1. Go to this page and download the library: Download bahaaalhagar/shoppingcart library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bahaaalhagar / shoppingcart example snippets


Cart::add($productModel, $qty);

Cart::add($productModel, $qty, ['size' => 'large', 'color' => 'black']);

$uinqueIndex = '20185a4530208f76b2ef3eb95307a021';

Cart::modify($uinqueIndex, 2); // Will modify the quantity

$uinqueIndex = '20185a4530208f76b2ef3eb95307a021';

Cart::reduceOneItem($uinqueIndex); // will reduce item quantity by 1

$uniqueIndex = '20185a4530208f76b2ef3eb95307a021';

Cart::remove($uniqueIndex);

Cart::getContent();

Cart::destroy();

Cart::total();

Cart::count();