這個(gè)需要修改一個(gè)程序文件 lib_goods.php
在文件末尾添加一個(gè)函數(shù)
代碼如下:
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 . " and o.order_status=1 " ;//o.order_status=1 表示確認(rèn)了的訂單才算
return $GLOBALS['db']->getOne($sql);
}
然后找到在get_recommend_goods函數(shù)中 大致325行 $goods[$idx]['url']= build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
其后添加
$goods[$idx]['buy_num']= get_buy_sum($row['goods_id']);
剩下的就是通過(guò)在模板中用
代碼如下:
{if $goods.buy_num}
{$goods.buy_num}
{else}
0
{/if}
調(diào)用了
代號(hào)極光
出處:http://zizhuyuan.cnblogs.com
更多信息請(qǐng)查看IT技術(shù)專欄