通過學(xué)習(xí)、查詢,解決該問題。
方案如下:
修改 includes/lib_insert.php 文件,
增加一個(gè)函數(shù)
代碼如下:
/**
* 調(diào)用某商品的累積售出
*/
function insert_goods_sells($arr)
{
$sql = 'select sum(goods_number) as number ' .
' from ' . $globals['ecs']->table('order_goods') . as og , . $globals['ecs']->table('order_info') . as o .
where og.order_id = o.order_id and og.goods_id=.$arr['goods_id'];
$row = $globals['db']->getrow($sql);
if ($row)
{
$number = intval($row['number']);
}
else
{
$number = 0;
}
return $number;
}
修改模板下goods.dwt文件
增加一行代碼
<strong>累計(jì)售出:</strong>{insert name='goods_sells' goods_id=$id}{$goods.measure_unit}