Download the PHP package overtrue/laravel-shopping-cart without Composer
On this page you can find all versions of the php package overtrue/laravel-shopping-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download overtrue/laravel-shopping-cart
More information about overtrue/laravel-shopping-cart
Files in overtrue/laravel-shopping-cart
Package laravel-shopping-cart
Short Description Shopping cart for Laravel Application.
License MIT
Informations about the package laravel-shopping-cart
Laravel Shopping Cart
Shopping cart for Laravel Application.
Installation
or add the following line to your project's composer.json:
then
After completion of the above, add the follow line to the section providers of config/app.php:
And add the follow line to the section aliases:
Usage
Add item to cart
Add a new item.
example:
Update item
Update the specified item.
example:
Get all items
Get all the items.
example:
Get item
Get the specified item.
example:
Remove item
Remove the specified item by raw ID.
example:
Destroy cart
Clean Shopping Cart.
example:
Total price
Returns the total of all items.
example:
Count rows
Return the number of rows.
example:
Count quantity
Returns the quantity of all items
$totalItems : When false,will return the number of rows.
example:
Search items
Search items by property.
example:
Check empty
Specifies the associated model
Specifies the associated model of item before you add items to cart.
example:
The Collection And Item
Collection and Overtrue\LaravelShoppingCart\Item are instanceof Illuminate\Support\Collection, Usage Refer to:Collections - Laravel doc.
properties of Overtrue\LaravelShoppingCart\Item:
id- your goods item ID.name- Name of item.qty- Quantity of item.price- Unit price of item.total- Total price of item.__raw_id- Unique ID of row.__model- Name of item associated Model.- ... custom attributes.
And methods:
rawId()- Return the raw ID of item.
Events
| Event Name | Parameters |
|---|---|
shopping_cart.adding |
($attributes, $cart); |
shopping_cart.added |
($attributes, $cart); |
shopping_cart.updating |
($row, $cart); |
shopping_cart.updated |
($row, $cart); |
shopping_cart.removing |
($row, $cart); |
shopping_cart.removed |
($row, $cart); |
shopping_cart.destroying |
($cart); |
shopping_cart.destroyed |
($cart); |
You can easily handle these events, for example:
PHP 扩展包开发
想知道如何从零开始构建 PHP 扩展包?
请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》
License
MIT

