1. Go to this page and download the library: Download riesenia/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/ */
riesenia / cart example snippets
use Riesenia\Cart\Cart;
// default is ([], true, 2)
$cart = new Cart();
$cart->setContext(['customer_id' => $_SESSION['customer_id']]);
$cart->setPricesWithVat(false);
$cart->setRoundingDecimals(4);
// adding item to cart ($product has to implement CartItemInterface)
$cart->addItem($product);
// set quantity of the item when adding to cart
$cart->addItem($anotherProduct, 3);
// when $product->getCartId() returns i.e. 'abc'
$cart->setItemQuantity('abc', 7);
// remove item
$cart->removeItem('abc');
// get totals of type 'product'
echo $cart->getTotal('product');
// get totals of type 'product' and 'service'
echo $cart->getTotal('product,service');
// get totals of all items except type 'product' and 'service'
echo $cart->getTotal('~product,service');
$cart = new Cart();
$cart->addItem($product, 3);
// get unit price without VAT
echo $cart->getItemPrice($product, 1, false);
// get weight of type 'product'
echo $cart->getWeight('product');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.