/** * 游客购物车信息 */ public function _indexcache() { $CartCache = new ModelCartCache(); $Product = new ModelProduct(); $product_list = $CartCache->Product(); if (!$product_list) { $this->redirect('/cart/empty'); } $items = $Product->CartGoodsCache($product_list); $total = $CartCache->Total(); $num = $total['total_num']; $amount = $total['total_price']; $this->render('index', array('item' => $items['item'], 'num' => $num, 'amount' => $amount)); }
/** * 购物车列表 * * @param string $member_id * @return array */ public static function Cart($member_id = '') { $Product = new ModelProduct(); if ($member_id) { $Cart = new ModelCart(); //判断临时数据库信息 $num = $Cart->CartProductSum($member_id); $cart_list = $Cart->Rows($member_id); $cart_list_new = $Product->CartGoods($cart_list); $item = isset($cart_list_new['item']) ? $cart_list_new['item'] : array(); $amount = $Cart->CartProductAmount($member_id); } else { $CartCache = new ModelCartCache(); $product_list = $CartCache->Product(); $cart_list_new = $Product->CartGoodsCache($product_list); $item = isset($cart_list_new['item']) ? $cart_list_new['item'] : array(); $total = $CartCache->Total(); $num = isset($total['total_num']) ? $total['total_num'] : 0; $amount = isset($total['total_price']) ? $total['total_price'] : 0.0; } return array('item' => $item, 'num' => $num, 'amount' => $amount); }