市面上大多數ecshop模板都沒有顯示商品銷售數量的功能,可是這個功能倒是大多數客戶須要的,下面最源碼給你們分享一下實現這個功能最簡單快捷,最方便的方法: php
一、打開includes/lib_insert.php文件,在該文件最後位置,也就是?>以前加入如下代碼 html
function insert_buy_sum($arr) sql
{ spa
$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 = " . $arr['goods_id'] ; code
total = $GLOBALS['db']->getOne($sql); htm
if(total){ get
return total; 源碼
}else{ it
return 0; io
}
}
二、在須要顯示銷售量的商品下面加入如下代碼
已售出:{insert name='buy_sum' goods_id=$goods.goods_id} 件
例如要給商品分類頁面的商品下面顯示銷售量,那就找到themes/當前模板/library/goods_list.lbi,在如下代碼下面增長上面那句代碼就行
<!--{if $goods.promote_price neq "" } -->
<font class="price">{$goods.promote_price}</font>
<!--{else}-->
<font class="price">{$goods.shop_price}</font>
<!--{/if}-->
其餘地方要顯示銷售量,只要找到對應文件,在要顯示的地方插入那句調用代碼便可。