如何在首页调用购买记录?

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家

怎样获取全部商品的购买记录 在首页显示最新的N条记录。
求大神帮忙!

回答:
这个改动挺大的。

ECSHOP学习资料:http://www.phpally.com




function get_bought_notes()
{

$sql = 'SELECT u.user_name, og.goods_number,og.goods_id,og.goods_name,oi.shipping_name ,oi.invoice_no, oi.add_time, IF(oi.order_status IN (2, 3, 4), 0, 1) AS order_status ' .
'FROM ' . $ecs->table('order_info') . ' AS oi LEFT JOIN ' . $ecs->table('users') . ' AS u ON oi.user_id = u.user_id, ' . $ecs->table('order_goods') . ' AS og ' .
'WHERE oi.order_id = og.order_id AND ' . time() . ' - oi.add_time < 2592000ORDER BY oi.add_time DESC LIMIT 5';
$bought_notes = $db->getAll($sql);
foreach($bought_notes as $idx=>$value)
{
$goods_id = $value['goods_id'];
$bought_notes[$idx]['goods_thumb'] = $db->getOne("select goods_thumb from ".$ecs->table('goods')." where goods_id='$goods_id'");
}
return $bought_notes;
}
齐大师的代码 我调用了下 不知为何没有获取