Introduction
A Cart Implementation for Laravel.
Supported Laravel Versions: 10, 11, 12, and 13.
For Laravel 9.0 and below, please use version 1.0
Upgrading from v2? See the Upgrade Guide for breaking changes and recommended v3 patterns.
Quick Example
// Add an item to the cart
\Cart::add(
1, // any unique id
'Product 1', // product name
19.99, // product price
2, // quantity
['size' => 'large'] // an array of extra attributes
);
// get the entire cart
$cartContents = \Cart::getContent();
// update an item already in the cart
\Cart::update(
1, // the same unique id that was used to add the item
['quantity' => 3] // the quantity to update
);
// remove the item by its id
\Cart::remove(1);
// get the total of the cart
$total = Cart::getTotal();
// clear it all when you've finished (like when you've stored the order)
\Cart::clear();