PHP code example of noahenrik / cart2go

1. Go to this page and download the library: Download noahenrik/cart2go 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/ */

    

noahenrik / cart2go example snippets


$cart = new \Cart\Cart();

$cart->addItemToCart($itemId, $amount);

//OR

$cart->addItemToCart($itemId);


$allCartItems = $cart->grabAllItems();

$allCartItems = $cart->grabAllItems();

foreach ($allCartItems as $key => $cartItem) {
  
  echo "Amount: " . $allCartItems[$key]['amount'] . " ItemId: " . $allCartItems[$key]['itemId'];
}    

$cart->reset();

$cart->grabItem($itemId);

$cart->removeItem($itemId);
terminal
composer dump-autoload