Downloads
Stars
Version
This package is an updated version of FreshBitsWeb's laravel-cart-manager package.
CartItemQuantityChanged
event.There are a few well maintained shopping cart packages available but I wanted to have a solution which feels like the Laravel way and is more coupled with the database and provides additional functionality like shipping charges, discount, tax, total, round off, guest carts, etc. out-of-box while staying a very easy to use package.
Let us decide when this package should be used:
composer require freshbitsweb/laravel-cart-manager
php artisan vendor:publish --tag=laravel-cart-manager-config
php artisan vendor:publish --tag=laravel-cart-manager-migrations
php artisan migrate
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Freshbitsweb\LaravelCartManager\Traits\Cartable;
class Product extends Model
{
use Cartable;
// ...
}
// Add to cart
$cart = Product::addToCart($productId);
// Remove from cart
$cart = cart()->removeAt($cartItemIndex);
// Apply discount
$cart = cart()->applyDiscount($percentage);
// Fetch cart
$cart = cart()->toArray();
The demo of the package can be found at - https://laravel-cart-manager.freshbits.in
Checkout the full documentation.
Run this command to run the tests of the package:
composer test
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details