lee-to / laravel-cart
Laravel cart module
0.5
2021-01-17 14:13 UTC
Requires
- php: ^7.3
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: 8.5.x-dev
README
Install
-
composer require lee-to/laravel-cart
-
php artisan vendor:publish --provider="Leeto\Cart\Providers\CartServiceProvider"
-
set models and tables in config cart.php
Usage
Get cart items
Cart::get();
Get all user carts
Cart::userCarts(optional USER_ID);
Add to cart
Cart::add(PRODUCT_ID, optional [VARIANT_ID_1, VARIANT_ID_2]);
Change quantity
Cart::quantity(CART_ITEM_ID, NEW_COUNT);
Total cart price
Cart::total();
Total cart count
Cart::count();
Remove
Cart::remove(CART_ITEM_ID);
Clear all
Cart::flush();