haska/laravel-cart is a Laravel package for laravel cart package.
It currently has 3 GitHub stars and 14 downloads on Packagist.
Install it with composer require haska/laravel-cart.
Discover more Laravel packages by haska
or browse all Laravel packages to compare alternatives.
Last updated
Provider:
'Haska\Cart\CartServiceProvider',
Alias:
'Cart' => 'Haska\Cart\Facade',
Config:
php artisan config:publish haska:laravel-cart
Examples:
// Format array of required info for item to be added to cart...
$items = array(
'id' => 1,
'name' => 'Product name',
'price' => 120.00,
'quantity' => 1
);
// Make the insert...
Cart::insert($items);
Cart::insert(array(
'id' => 'foo',
'name' => 'bar',
'price' => 100,
'quantity' => 1,
'tax' => 20
));
foreach (Cart::contents() as $item) {
$item->name = 'Foo';
$item->quantity = 1;
}
foreach (Cart::contents() as $item) {
$item->remove();
}
Cart::destroy()
Cart::contents();
Content passed like an array
Cart::contents(true);
Cart::totalItems();
Get only unique items
Cart::totalItems(true);
Cart::total();
Passed without tax rates
Cart::total(false);
Cart::has($id);
$item = Cart::item($id);
$item->total();
Without tax rates
$item->total(false);
if ($item->hasOptions()) {
// We have options
}
$item->remove();
$item->toArray();