實現ECSHOP商品詳情頁面顯示購買記錄有些ECSHOP模板開發(fā)時候沒有帶這個商品購買記錄,所以需要自己增加下:
在goods.php加入 代碼
$smarty->assign('sale_history',getsales_history($goods_id));//獲取購買歷史記錄
function getsales_history($goods_id){$sql ='select f.consignee, f.order_sn, f.address, g.goods_number,f.add_time FROM '. $GLOBALS['ecs']->table('order_goods') .' as g,'. $GLOBALS['ecs']->table('order_info') .' as f where g.order_id = f.order_id and g.goods_id='.$goods_id;$res = $GLOBALS['db']->getAll($sql);$sales_history = array();foreach ($res AS $idx => $row){
$sales_history[$idx]['name'] = $row['consignee'];
$sales_history[$idx]['order_sn'] = $row['order_sn']; $sales_history[$idx]['address'] = $row['address'];
$sales_history[$idx]['number'] = $row['goods_number'];
//$sales_history[$idx]['add_time'] = local_date("Y-m-d", $row['add_time']);
$sales_history[$idx]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']);
}
return $sales_history;}
在goods.dwt中加入 代碼
歷史購買記錄 名字 訂單號 地址 數量 日期
{$saleitem.name} {$saleitem.order_sn} {$saleitem.address} | {$saleitem.number} | {$saleitem.add_time}
|