1. Go to this page and download the library: Download atakajlo/shopping-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/ */
atakajlo / shopping-cart example snippets
use atakajlo\cart\cost\calculator\SimpleCalculator;
use atakajlo\cart\Cart;
use atakajlo\cart\item\CartItem;
use atakajlo\cart\storage\SessionStorage;
use atakajlo\cart\sort\IdComparator;
$cart = new Cart(
new SessionStorage(),
new SimpleCalculator(),
new IdComparator() //optional
);
$cartItem = new CartItem(1, 100, 1);
$cart->add($cartItem);
$cart->changeQuantityById($cartItem->getId(), 5);
$items = $cart->getItems();
$totalCost = $cart->getCost()->getTotal();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.