Downloads
Stars
Version
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
You can install the package via composer:
composer require masterix21/laravel-cart
You can publish and run the migrations with:
php artisan vendor:publish --provider="Masterix21\LaravelCart\CartServiceProvider" --tag="laravel-cart-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="Masterix21\LaravelCart\CartServiceProvider" --tag="laravel-cart-config"
$product = YourProductModel::first();
//
// Add a product to cart
$cartItem = Cart::add(label: $product->name, item: $product, price: $product->price, quantity: 1);
//
// Change the cart item quantity
Cart::set($cartItem, 2); // or
$cartItem->setQuantity(2);
//
// Increase the cart item quantity
Cart::increase($cartItem); // to increase of 1
Cart::increase($cartItem, 5); // to increase of 5
$cartItem->increase(); // to increase of 1
$cartItem->increase(5); // to increase of 5
//
// Decrease the cart item quantity, and if the
// quantity is zero, removes the item from the cart.
Cart::decrease($cartItem); // to decrease of 1
Cart::decrease($cartItem, 5); // to decrease of 5
$cartItem->decrease(); // to decrease of 1
$cartItem->decrease(5); // to decrease of 5
// Retrieve all cart items
$items = Cart::items();
// Clear the cart
Cart::clear();
Display the cart items counter that will auto-refresh on cart changes:
<!-- Automatic refresh the counter -->
<livewire:cart-counter />
<!-- Force the displayed value -->
<livewire:cart-counter :count="10" no-auto-refresh />
<!-- Customize the component using class argument like so -->
<livewire:cart-counter class="text-xs text-white rounded-full bg-red-700" />
<!-- Improve the result by its state -->
<livewire:cart-counter class="text-xs rounded-full"
empty-class="bg-gray-100 text-gray-500"
not-empty-class="bg-red-700 text-white" />
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.