aharen / cart
Simple Session based cart for shopping websites
Installs: 58
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/aharen/cart
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2025-10-26 00:40:24 UTC
README
Simple Session based cart for shopping websites in Laravel
Installation
composer require aharen/cart
Configuration
-
Add
CartServiceProvidertoprovidersinconfig/app.phpaharen\Cart\CartServiceProvider::class,
-
Add
CartFacade toaliasesinconfig/app.php'Cart' => aharen\Cart\CartFacade::class,
-
Publish the config file to
configfolderphp artisan vendor:publish
If so some reason it doesn't create the config file you have to create a file named cart.php inside the config folder with the contents below
<?php
return [
'name' => 'yourcartnamehere',
];
Usage
Get items currently in cart
Get the current contents of the cart. Will return false if the cart is empty
Cart::get();
Count items currently in cart
Cart::count();
Add item to cart
The first parameter is your item. It can either be an ID or item name. The second parameter has to be numeric which is the Quantity.
Cart::add('Pizza Slice', 2);
Remove Item from cart
Accepts only 1 parameter, which is your item ID or item name
Cart::remove('Pizza Slice');
Reset the cart
Empties your current cart
Cart::reset();