indigophp / cart
此包已被弃用且不再维护。未建议替代包。
购物车抽象层
v2.0.0
2014-09-22 07:11 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- codeception/codeception: ~2.0.0
- codeception/mockery-module: dev-master
This package is auto-updated.
Last update: 2021-11-24 09:13:15 UTC
README
购物车抽象层。
安装
通过 Composer
$ composer require indigophp/cart
用法
要查看概念实现示例,请查看这个库。
use Indigo\Cart\Cart; use Indigo\Cart\Item; use Indigo\Cart\Store; /* Note: these are interfaces, you cannot instantiate them */ $cart = new Cart; $cart->addItem(new Item); // Get total price $cart->getTotal(); // Get item count (item * quantity) $cart->getQuantity(); foreach($cart->getItems() as $id => $item) { // Get subtotal $item->getSubtotal(); // Get price $item->getPrice(); // Get name $item->getName(); } // Throws an Indigo\Cart\Exception\ItemNotFound $cart->getItem('non_existent'); $store = new Store; $store->save($cart);
获取现有购物车
use Indigo\Cart\Store; $store = new Store; $cart = $store->find('cart_id'); // Throws an Indigo\Cart\Exception\CartNotFound $store->find('non_existent');
测试
$ phpspec run
贡献
请参阅CONTRIBUTING以获取详细信息。
致谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅许可文件。