ankurk91 / laravel-shopping-cart
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
Laravel购物车管理器。
安装
您可以通过composer安装此包
composer require "ankurk91/laravel-shopping-cart"
使用
您可以使用外观
<?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();
或者您可以从容器中定位它
<?php use Ankurk91\LaravelShoppingCart; $shoppingCart = app(ShoppingCartManager::class); $shoppingCart->all();
注意 购物车项目将存储在默认会话存储中。
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG
测试
composer test
安全
如果您发现任何安全问题,请通过电子邮件 pro.ankurk1[at]gmail[dot]com
而不是使用问题跟踪器。
归属
此包深受 overtrue/laravel-shopping-cart 启发。
许可证
MIT 许可证。