gabrielcabola / simple-shopping-cart
PHP 5.4.x 简单购物车
dev-master
2018-12-07 21:12 UTC
Requires
- php: >=5.3
This package is auto-updated.
Last update: 2024-09-09 02:41:15 UTC
README
Simple-shopping-cart
PHP 5.4.x 简单购物车类
如何使用
加载类
//composer autoload (ignore if do you already have) require '../vendor/autoload.php'; //load the class use SSCart\Cart; //Initialize $cart = new Cart([array $options]);
选项
添加
// Add a product $cart->add([object $product]);
更改数量
更多(向上)
// Increase Item Quantity $cart->upQuantity(id,amount); //or use only to increase one $cart->upQuantity(id);
更少(向下)
// Decrease Item Quantity $cart->downQuantity(id,amount); //or use only to decrease one $cart->downQuantity(id);
移除项目
// Decrease Item Quantity $cart->remove(id);
列出所有项目
// List $cart->items();
产品总数
// Get a integer number of distinct products in cart $cart->productsTotal();
项目总数
// Get a integer number of itens total in cart $cart->itemsTotal();
购物车总金额
// Show total cost of cart $cart->sumTotal()
清空购物车
// Cleat entire Cart $cart->clearCart
辅助工具
使用辅助工具
//Price sub class use SSCart/Price; //Format price and decimals Price::format($number); //Return Class currency ($ default) Price::currency();
返回格式化价格。
示例
运行一个简单的应用程序以展示购物车的工作原理!
/example/index.php