ECSHOP二次开发:ECSHOP首页购物车中商品数量调用
作者:我就是个世界
发表于:2013-07-03
有时候我们需要单独调用购物车中商品的数量,来放在模版中使用。此时就需要用到下边这个函数了。
打开:includes/lib_insert.php文件
在lib_insert.php文件中的适当位置(例如如function insert_cart_info()函数后面)加上:[separator]
[code]
/**
* 调用购物车商品数目
*/
function insert_cart_info_number()
{
$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;
}
[/code]
lbi中调用购物车数量:[code]{insert name='cart_info_number'}[/code]
就这么简单!其实就是仿造了一下insert_cart_info()函数
打开:includes/lib_insert.php文件
在lib_insert.php文件中的适当位置(例如如function insert_cart_info()函数后面)加上:[separator]
[code]
/**
* 调用购物车商品数目
*/
function insert_cart_info_number()
{
$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;
}
[/code]
lbi中调用购物车数量:[code]{insert name='cart_info_number'}[/code]
就这么简单!其实就是仿造了一下insert_cart_info()函数
请发表您的评论