ecshop购物车随会员退出自动清空问题
ecshop购物车不是很好用,有时候特定的需求下,需要将购买的物品保留,或者当会员登陆买东西之后,不小心关闭浏览器,或者是退出的时候,还可以让商品保留在购物车,如果下次登陆,还可以看到购物车的产品.
这样就实现了购物车在退出的情况下,只要登陆的时候购买的产品,都可以保留下来.
1:修改includes/cls_session.php中的 destroy_session()函数
其实就是后面多加个user_id ='' www.phpfensi.com
$this->db->query('DELETE FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '$this->session_id' and user_id =''");
2:lib_main.php文件中的update_user_info()函数 www.phpfensi.com
把下面的返回值去了!
- $sql = "update ".$GLOBALS['ecs']->table('cart')." set user_id =".$_SESSION['user_id']." where session_id = '".SESS_ID."'";
- $GLOBALS['db'] -> query($sql);
- $sql1 = "update ".$GLOBALS['ecs']->table('cart')." set session_id ='".SESS_ID."' where user_id = '".$_SESSION['user_id']."'";
- $GLOBALS['db'] -> query($sql1);
- $re = $GLOBALS['db'] -> getAll("select *,sum(goods_number) as goods_number from ".$GLOBALS['ecs']->table('cart')." where user_id = '{$_SESSION['user_id']}' and session_id = '".SESS_ID."' group by goods_id");
- if($re){
- foreach ($re as $k => $v){
- $sql = "update ".$GLOBALS['ecs']->table('cart'). " set goods_number = ".$v['goods_number']." where rec_id = ".$v['rec_id'];
- $GLOBALS['db'] -> query($sql);
- $sql = "delete from ".$GLOBALS['ecs']->table('cart')." where rec_id <> {$v['rec_id']} and user_id = '{$_SESSION['user_id']}' and session_id = '".SESS_ID."' and goods_id = ".$v['goods_id'];
- $GLOBALS['db'] -> query($sql);
- }
- }
这样就可以实现了。

