ecshop调用购物车商品数量方法

1、打开 includes/lib_insert.php

 

2、在最后位置添加如下代码:

  1. /**
  2. * 调用购物车商品数目
  3. */
  4. function insert_cart_mes_num()
  5. {
  6. $sql = 'SELECT SUM(goods_number) AS number, SUM(goods_price * goods_number) AS amount' .
  7.            ' FROM ' . $GLOBALS['ecs']->table('cart') .
  8. " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'";
  9. $row = $GLOBALS['db']->GetRow($sql);
  10. if ($row)
  11.     {
  12. $number = intval($row['number']);
  13. $amount = floatval($row['amount']);
  14.     }
  15. else
  16.     {
  17. $number = 0;
  18. $amount = 0;
  19.     }
  20. $str = sprintf($number, price_format($amount, false));
  21. return $str;
  22. }

 

3、 在模板页使用   {insert name='cart_mes_num'}    调用即可!

 

ecshop购物车商品数量

    A+
发布日期:2017年08月11日 15:28:01  所属分类:Ecshop
最后更新时间:2017-08-11 15:40:03
付杰
  • ¥ 298.0元
  • 市场价:398.0元
  • ¥ 89.0元
  • 市场价:129.0元
  • ¥ 98.0元
  • 市场价:198.0元
  • ¥ 69.0元
  • 市场价:99.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: