ecshop首页商品显示购买过的次数

2016-09-07 22:02 来源:www.chinab4c.com 作者:ecshop专家

ecshop首页商品显示购买过的次数

修改一个程序文件 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 . "  and o.order_status=1 "  ;//o.order_status=1 表示确认了的订单才算
    return $GLOBALS['db']->getOne($sql);
}

 

然后找到 在get_recommend_goods函数中 大致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']);

 

剩下的就是通过在模板中 用
{if $goods.buy_num}
{$goods.buy_num}
{else}
0
{/if}


调用了

(责任编辑:chinab4c)