Simple framework agnostic shopping cart.
This is been ported over from https://github.com/anam-hossain/phpcart this version has been configured to work with Nova Framework.
- Simple API
- Support multiple cart instances
- Nova Framework integration
- PHP 5.4+
Download this repo and place inside the Shared
folder.
open the config/app.php
In the $providers array add the following service provider.
'Shared\Cart\CartServiceProvider'
Add the facade of this package to the $aliases array.
'Cart' => 'Shared\Cart\Facades\Cart'
You can now use this facade in place of instantiating the Cart yourself.
The add method required id
, name
, price
and quantity
keys. However, you can pass any data that your application required.
Cart::add([
'id' => 1001,
'name' => 'Skinny Jeans',
'quantity' => 1,
'price' => 90
]);
Cart::update([
'id' => 1001,
'name' => 'Hoodie'
]);
Cart::updateQty(1001, 3);
Cart::updatePrice(1001, 30);
Cart::remove(1001);
Cart::getItems();
// or
Cart::items();
Cart::get(1001);
Cart::has(1001);
Cart::count();
Cart::totalQuantity();
Cart::getTotal();
Cart::clear();
PHPCart supports multiple cart instances, so that you can have as many shopping cart instances on the same page as you want without any conflicts.
$cart = new Cart('cart1');
// or
$cart->setCart('cart2');
$cart->add([
'id' => 1001,
'name' => 'Skinny Jeans',
'quantity' => 1,
'price' => 90
]);
//or
$cart->named('cart3')->add([
'id' => 1001,
'name' => 'Jeans',
'quantity' => 2,
'price' => 100
]);