funayaki / cakephp-cart
本包最新版本(0.0.1)没有提供许可证信息。
CakePHP 购物车插件
0.0.1
2018-12-19 08:58 UTC
Requires
- php: >=5.6
- cakephp/cakephp: >=3.3.2 <4.0.0
Requires (Dev)
- phpunit/phpunit: ^5.7|^6.0
This package is not auto-updated.
Last update: 2024-09-15 05:02:58 UTC
README
CakePHP 购物车插件
要求
- CakePHP 3.5.0 或更高版本
安装
您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。
安装 composer 包的推荐方式是
composer require funayaki/cakephp-cart
实现 EntityBuyableAwareInterface
class Item extends Entity implements EntityBuyableAwareInterface { public function getPrice() { return $this->price; } public function getBuyableLimit() { return INF; } }
加载 CartComponent
<?php class AppController extends Controller { public function initialize() { parent::initialize(); $this->loadComponent('Cart.Cart'); } }
使用方法
向购物车添加商品
$this->Cart->add($item);
更新购物车中商品的数量
$this->Cart->edit($item, 5);
获取购物车中的商品
$this->Cart->get($item); $this->Cart->get();
计算购物车中商品的总额
$this->Cart->total($item);
计算购物车的总金额
$this->Cart->total();
计算购物车中商品的数量
$this->Cart->count($item); $this->Cart->count();
从购物车中删除商品
$this->Cart->delete($item);
从购物车中删除所有商品
$this->Cart->clear();