1.在ecshop程序根目录下goods.php页面最下面加入这函数
~~~
function get_buy_sum($goods_id)
{
$sql = 'SELECT IFNULL(SUM(g.goods_number), 0) ' .
'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o, ' .
$GLOBALS['ecs']->table('order_goods') . ' AS g ' .
"WHERE o.order_id = g.order_id " .
"AND o.order_status = '" . OS_CONFIRMED . "' " .
"AND o.shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) .
" AND o.pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) .
" AND g.goods_id = '$goods_id'";
return $GLOBALS['db']->getOne($sql);
}
~~~
2.修改category.php
里面的找到 `category_get_goods`函数
`
$arr[$row['goods_id']]['type'] = $row['goods_type'];
`
在下面加
`
$arr[$row['goods_id']]['buy_num'] = get_buy_sum($row['goods_id']);
`
3.调用页面在goods_list.lbi合适的位置加
~~~
{if $goods.buy_num}
{$goods.buy_num}
{else}
0
{/if}
~~~