anwar7736 / shoppingcart
使用laravel制作一个简单的购物车包
dev-main
2023-06-03 15:57 UTC
This package is auto-updated.
Last update: 2024-09-03 18:47:02 UTC
README
这是一个laravel简单购物车包。您可以使用此包非常容易。请按照以下说明使用此包。
安装
composer require anwar7736/shoppingcart
配置
- 打开 config/app.php 并将此行添加到您的服务提供者数组中。
Anwar\ShoppingCart\ShoppingCartServiceProvider::class
- 打开 config/app.php 并将此行添加到您的别名中
'Cart' => Anwar\ShoppingCart\Facades\Cart::class
- 可选配置 文件(如果您计划完全控制,则很有用)
php artisan vendor:publish --provider="Anwar\ShoppingCart\ShoppingCartServiceProvider"
如何使用
use Anwar\ShoppingCart\Facades\Cart; //Add single item to cart Cart::add(id, name, quantity, price, discount(optional), variation(optional), image(optional)); //Get single item from cart Cart::get(id); //Update single item from cart(you can update quantity or variation or both) Cart::update(id, quantity(optional), variation(optional)); //Remove single item from cart Cart::remove(id); //Get how many items in your cart Cart::count(); //Get all cart items Cart::content(); //Get total discount amount in your cart Cart::discount(); //Get subtotal in your cart Cart::subtotal(); //Remove all items from your cart Cart::destroy();