ankurk91 / laravel-shopping-cart
Shopping cart manager for Laravel
1.5.0
2024-03-07 15:25 UTC
Requires
- php: ^8.2
- illuminate/collections: ^10 || ^11
- illuminate/session: ^10 || ^11
- illuminate/support: ^10 || ^11
Requires (Dev)
- orchestra/testbench: ^8.0 || ^9.0
- phpunit/phpunit: ^9.5 || ^10.0
README
Shopping cart manager for Laravel.
Installation
You can install the package via composer:
composer require "ankurk91/laravel-shopping-cart"
Usage
You can use Facade
<?php use Ankurk91\LaravelShoppingCart\Facades\ShoppingCart; use App\Models\Product; $product = Product::find(1); $quantity = request('quantity'); $attributes = [ 'image_url' => asset('image.webp'), ]; $item = ShoppingCart::add( $product, $product->name, $product->unit_price, $quantity, $attributes, ); ShoppingCart::find(1); ShoppingCart::update($product->id, 3); ShoppingCart::all(); ShoppingCart::count(); ShoppingCart::has($product); ShoppingCart::isEmpty(); ShoppingCart::subtotal(); ShoppingCart::remove($product->getKey()); ShoppingCart::clear();
Or you can locate it from container
<?php use Ankurk91\LaravelShoppingCart; $shoppingCart = app(ShoppingCartManager::class); $shoppingCart->all();
Note The cart items will be stored in default session storage.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
composer test
Security
If you discover any security issues, please email pro.ankurk1[at]gmail[dot]com
instead of using the issue tracker.
Attribution
This package is highly inspired by overtrue/laravel-shopping-cart
License
The MIT License.