dev-master
9999999-dev https://indigophp.comSimple implementation of Indigo Cart
MIT
The Requires
- php >=5.4
- indigophp/cart 3.0.*@dev
The Development Requires
by MĂĄrk SĂĄgi-KazĂĄr
simple cart
Wallogit.com
2017 © Pedro PelĂĄez
Simple implementation of Indigo Cart
Simple implementation of Indigo Cart., (*2)
Via Composer, (*3)
``` bash $ composer require indigophp/simple-cart, (*4)
## Usage ``` php use Indigo\Cart\Cart; use Indigo\Cart\Item; use Indigo\Cart\Store; /* Note: these are interfaces, you cannot instantiate them */ $cart = new Cart\Simple; // Throws an exception if any of these are invalid // name, price, quantity [, id] $cart->addItem(new Item\Simple('Item', 1, 1, '_ITEM_')); // Get total price $cart->getTotal(); // Get item count (item * quantity) $cart->getQuantity(); foreach($cart->getItems() as $id => $item) { // Get subtotal $item->getSubtotal(); // Get price $item->getPrice(); // Get name $item->getName(); } // Throws an Indigo\Cart\Exception\ItemNotFound $cart->getItem('non_existent'); // Accepts a session key $store = new Store\Session('cart'); $store->save($cart);
Get existing cart:, (*5)
``` php use Indigo\Cart\Store;, (*6)
$store = new Store\Session('cart'); $cart = $store->find('cart_id');, (*7)
// Throws an Indigo\Cart\Exception\CartNotFound $store->find('non_existent');, (*8)
## Testing ``` bash $ phpspec run
Please see CONTRIBUTING for details., (*9)
The MIT License (MIT). Please see License File for more information., (*10)
Simple implementation of Indigo Cart
MIT
simple cart