ecshop调用显示购物车商品数量

文件:include/lib_insert.php

/**
* 调用购物车商品数目
*/
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;
}

ECSHOP模版页显示:

{insert name='cart_info_number'}

 

posted @ 2013-05-08 13:39  做个好男人  阅读(329)  评论(0编辑  收藏  举报