matthewbdaly/laravel-cart is a Laravel package for simple laravel shopping cart.
It currently has 2 GitHub stars and 51 downloads on Packagist (latest version 0.0.4).
Install it with composer require matthewbdaly/laravel-cart.
Discover more Laravel packages by matthewbdaly
or browse all Laravel packages to compare alternatives.
Last updated
Simple shopping cart implementation for Laravel. Loosely inspired by CodeIgniter's cart class.
composer require matthewbdaly/laravel-cart
The cart implements the interface Matthewbdaly\LaravelCart\Contracts\Services\Cart, so you can use that to type-hint it. Alternatively you can use the Cart facade.
To add an item, call $cart->insert($data). In this case $data must be an array with the following fields:
qtypricenameoptionsOR an array of items, each with the same fields. You can also add any additional data you wish.
Call $cart->all() to retrieve the contents.
Call $cart->get($rowId) to retrieve an item by its row ID.
Call $cart->update($rowId, $data) to update an item with the provided data.
Call $cart->remove($rowId) to remove an item.
Call $cart->total() to get the total price.
Call $cart->totalItems() to get a count of the items. Note that this does not allow for the quantity - if you have item X with a quantity of 2, that will be 1 item in the count.
Call $cart->destroy() to destroy the cart.