1. Go to this page and download the library: Download darthsoup/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/ */
darthsoup / shoppingcart example snippets
/**
* Add a Item to the cart.
*
* @param string|array $id Unique ID of the item|Item formatted as array|Array of items
* @param string $name Name of the item
* @param int $quantity Item quantity to add to the cart
* @param float $price Price of one item
* @param array $options Array of additional options, such as 'size' or 'color'
*/
// Basic form
Cart::add('1', 'Product One', 1, 9.99, ['option_key' => 'option_value']);
// Array form
Cart::add(['id' => 'mail1000', 'name' => 'Mail Package One', 'quantity' => 5, 'price' => 4.99, 'options' => []]);
// Batch method
Cart::add([
['id' => '15', 'name' => 'Hamburger', 'quantity' => 1, 'price' => 1.99],
['id' => '16', 'name' => 'Cheeseburger', 'quantity' => 1, 'price' => 2.49, 'options' => ['onion' => false]]
]);
$item = new \DarthSoup\Cart\Item('15', 'Hamburger', 1.99, ['onion' => false]);
Cart::add($item);