ECshop商品列表页及详细页显示商品的出售量
发表时间: 2015-04-09 15:01:08 | 浏览次数:
1.打开includes/lib_goods.php,在文件中添加以下方法:
/** * 查询商品的出售数量 * @param int $goods_id 商品id * @return int */ function sales_volume($goods_id) { $sql= "select sum(goods_number) as count from ".$GLOBALS['ecs']->table('order_goods')." where goods_id = '$goods_id'"; $res = $GLOBALS['db']->getOne($sql); if($res>0){ return $res; }else{ return('0'); } }
2.打开category.php文件,在大概516行(while循环中)插入:$arr[$row['goods_id']]['sales_volume'] = sales_volume($row['goods_id']); 调用代码为:{$goods.sales_volume}
3.打开goods.php文件,在大概190行处插入代码:$goods['sales_volume'] = sales_volume($goods_id); 调用代码为:{$goods.sales_volume}
效果如下图所示
(by:LiuR_Fun-刘锐芬)
上一篇:ECshop商品增加[按点击率排行]
下一篇:没有了