1、在includes/lib_goods.php文件末尾加入以下代码
function get_buy_sum($goods_id){$sql = "select sum(goods_number) from " . $GLOBALS['ecs']->table('order_goods') . " AS g ,".$GLOBALS['ecs']->table('order_info') . " AS o WHERE o.order_id=g.order_id and g.goods_id = " . $goods_id ; return $GLOBALS['db']->getOne($sql);}
2、搜索找到下面代码,317行左右
$goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
3、在后面添加
$goods[$idx]['buy_num']= get_buy_sum($row['goods_id']);
4、在首页适当位置加入以下代码
{ if $goods.buy_num}{ $goods.buy_num}{ else}0{ /if}