1. 程式人生 > >【ecshop】調用購物車商品數量

【ecshop】調用購物車商品數量

from num tab car pan rec 商品 lob select

1 打開 includes/lib_insert.php 在最後位置添加如下代碼:

 
/**
* 調用購物車商品數目
*/
function insert_cart_mes_num()
{
    $sql = ‘SELECT SUM(goods_number) AS number, SUM(goods_price * goods_number) AS amount‘ .
           ‘ FROM ‘ . $GLOBALS[‘ecs‘]->table(‘cart‘) .
           " WHERE session_id = ‘" . SESS_ID . "‘ AND rec_type = ‘" . CART_GENERAL_GOODS . "‘";
    
$row = $GLOBALS[‘db‘]->GetRow($sql); if ($row) { $number = intval($row[‘number‘]); $amount = floatval($row[‘amount‘]); } else { $number = 0; $amount = 0; } $str = sprintf($number, price_format($amount, false)); return $str; }

2 在模板頁使用 {insert name=‘cart_mes_num‘} 調用即可

【ecshop】調用購物車商品數量