PHP code example of metator / cart
1. Go to this page and download the library: Download metator/cart 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/ */
metator / cart example snippets
use Metator\Cart\Cart;
$cart = new Cart;
$cart->add(5);
$cart->add(5);
$cart->add(5);
echo $cart->quantity(5); // 3
print_r($cart->items()); // array(5)
$cart->remove(5);
echo $cart->quantity(5); // 0
print_r($cart->items()); // array()
$cart->add(5);
$cart->setQuantity(5,500);
echo $cart->quantity(5); // 500
$cart->setQuantity(5,0);
print_r($cart->items()); // array()