自动显示同一会员上次购买同一产品的价格功能

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

头一次发布程序,希望能对大家有帮助。
需求:同一会员在上次购买一个商品以后,后台管理员将订单中此商品的价格进行了修改,下次此会员再次购买此商品时,不显示网站制定的价格,而是自动调出最新一次购买此商品的订单中的价格。
实现:在includes/lib_order.php中修改get_cart_goods()方法,在 while ($row = $GLOBALS['db']->fetchRow($res))中添加如下程序//查询统一会员购买同一商品时上次的价格
$order_goods_id=$row[goods_id];
$sql_order_list = "SELECT order_id FROM ".$GLOBALS['ecs']->table('order_info') ."WHERE user_id='$_SESSION[user_id]' ORDER BY add_time desc";
$res_order_list = $GLOBALS['db']->query($sql_order_list);
while ($row_order_list = $GLOBALS['db']->fetchRow($res_order_list)){
$sql_order_goods = "SELECT * FROM ".$GLOBALS['ecs']->table('order_goods') ." WHERE order_id = '$row_order_list[order_id]' and goods_id ='$order_goods_id ' ORDER BY rec_id DESC LIMIT 1";
$res_order_goods = $GLOBALS['db']->query($sql_order_goods);
while($row_order_goods = $GLOBALS['db']->fetchRow($res_order_goods)){
if($row_order_goods[goods_price]){
$order_goods_price = $row_order_goods[goods_price];
}
}
if($order_goods_price){
$row['goods_price'] = $order_goods_price;
break;
}
}

本地测试成功,希望大家踊跃测试,发现问题可以随时联系本人QQ:176244726.

回答:
好贴子,多谢高手共享!