Download the PHP package yzh52521/think-shop-cart without Composer
On this page you can find all versions of the php package yzh52521/think-shop-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yzh52521/think-shop-cart
More information about yzh52521/think-shop-cart
Files in yzh52521/think-shop-cart
Package think-shop-cart
Short Description Shopping cart for ThinkPHP Application.
License MIT
Informations about the package think-shop-cart
购物车在电商场景中基本是必须的一个模块,本包是基于 [overtrue/laravel-shopping-cart] 进行扩展开发,主要实现了以下扩展:
- 购物车数据支持 Database 存储
- Item 增加 Model 属性返回。因为购物车可能是SPU或者SKU,因此直接通过 model 属性直接返回相关对象。
- 支持多 Guard. 商城购物车和导购购物车。
已经完成了 Session 和 Database 模式下的单元测试 可放心使用.
Installation
会话初始化
app\middleware.php
Usage
Select Storage
You can change data Storage in config/cart.php
file.
If you use Database Storage, you need to execute
发布配置文件和数据库迁移文件:
执行迁移工具(确保数据库配置信息正确):
这将创建名为 shopping_cart
的表。
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.
session example:
database example:
The Collection And Item
properties of yzh52521\ShoppingCart\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.License
MIT
All versions of think-shop-cart with dependencies
ext-json Version *