function _displayCart() { $comm_cart = array(0, 0); if (isset($_SESSION['cart'])) { $cartObj = CartHelper::getCart(); $comm_cart[0] = $cartObj->getItemCount(); $comm_cart[1] = $cartObj->getPrice(); } return $comm_cart; }
<?php /* 购物车控制器 */ define('ACC', true); require '../system/init.php'; //实例化购物车类和商品类 $cartObj = CartHelper::getCart(); $goods = new GoodsModel(); $act = isset($_GET['act']) ? $_GET['act'] : 'buy'; //购买商品,去结算 if ($act == 'buy') { if (isset($_GET['goods_id'])) { $goods_id = $_GET['goods_id']; $goods_info = $goods->find($goods_id); $num = isset($_GET['num']) ? $_GET['num'] + 0 : 1; //商品是否存在 if (!isset($goods_info)) { $msg = "The ware is not exist<br>"; include __ROOT__ . 'view/front/msg.html'; exit; } //商品是否上架或者删除 if ($goods_info['is_delete'] || !$goods_info['is_on_sale']) { $msg = "The ware is not available<br>"; include __ROOT__ . 'view/front/msg.html'; exit; } //商品是否有库存 if ($cartObj->getNoByID($goods_id) + $num > $goods_info['goods_number']) {