当前位置:首页>文章>ecshop 详情页显示当前销量

ecshop 详情页显示当前销量

2017-03-29 1753 文章

打开根目录下的 goods.php 文件

最下方的 ?> 上面添加
  1. function selled_countgoods($goods_id){
  2. $sql= "select sum(goods_number) as count from".$GLOBALS['ecs']->table('order_goods')."where goods_id = '".$goods_id."'";
  3. $res = $GLOBALS['db']->getOne($sql);
  4. if($res>0){
  5. return $res;
  6. }
  7. else{
  8. return('0');
  9. }
  10. }
查找
  1. $smarty->display('goods.dwt', $cache_id);
上方空一行添加
  1. $smarty->assign('order_num',selled_countgoods($goods_id));

打开 themes/主题名称/goods.dwt 文件

在相应需要展示销量的位置,添加 {$order_num} 。 完毕!

评论 (0)