经常有不同用户留言,ecshop偶很猥琐悄然无声的将浏览器窗口关闭了,俺多年积累到到购物车的商品瞬间灰飞烟灭,此刻你叫我怎么淡定,比火球还火的怒火就在这一刻爆发了,亲爱的管理员,客户悄然流失,订单一天比一天少,你还如此淡定吗?想挽回这一切损失吗?赶紧跟着我来一步一步往下做吧,客户不断,掌声响起,闲来蛋疼,先闭嘴,废话少说,进入主题,开始修改了喽
找到includes/cls_session.php大约在268行查找下面代码:
复制内容到剪贴板折叠PHP 代码
-
if (!emptyempty($GLOBALS['ecs']))
-
{
-
$this->db->query('DELETE FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '$this->session_id'");
-
}
替换为:
复制内容到剪贴板折叠XML/HTML 代码
-
if (!empty($GLOBALS['ecs']))
-
{
-
$this->db->query('DELETE FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '$this->session_id' and user_id =''");
-
}
接下来,在同目录下找到lib_main.php定位到页面的最后,新增加一段代码以完成购物车不再被清空的烦恼。
复制内容到剪贴板折叠PHP 代码
-
-
$sql = "update ".$GLOBALS['ecs']->table('cart')." set user_id =".$_SESSION['user_id']." where session_id = '".SESS_ID."'";
-
$GLOBALS['db'] -> query($sql);
-
l1 = "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);
-
}
-
}
到这里一切搞定,记住后台更新缓存后测试下,是不是真的搞定了,如果有还问题,您可以联系一商设计二次开发的哦。
(责任编辑:好模板) |