ECTouch会员退出登录保留购物车里的商品

2018-11-23 15:40:29 admin
  1. 1. 打开/mobile/include/library/EcsApiSession.class.php和/mobile/include/library/EcsSession.class.php两个文件查找   $this->db->query('DELETE FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '$this->session_id'");(大概202行)分别注释掉

  2. 2. 打开/mobile/include/apps/default/model/UsersModel.class.php

    搜索如下代码: function update_user_info() {

    在该函数内末尾添加如下代码:


            /* 更新用户购物车,退出不清空购物车 */
        $sql = "UPDATE " . $this->pre . "cart SET".
               " user_id = '" . $_SESSION['user_id'] . "'".
               " WHERE session_id = '" . SESS_ID . "'";
        $this->query($sql);
        $sql = "UPDATE " . $this->pre . "cart SET".
               " session_id = '" . SESS_ID . "'".
               " WHERE user_id = '" . $_SESSION['user_id'] . "'";
       $this->query($sql);
        /* 删除购物车中已下架的商品 */
        $sql = "SELECT DISTINCT(c.goods_id) FROM " . $this->pre . "cart AS c left JOIN " . $this->pre . "goods AS g on c.goods_id = g.goods_id WHERE g.is_on_sale = 0 AND c.user_id = '" . $_SESSION['user_id'] . "'";
        $data = $this ->getFields($sql);
        if($data){
            foreach ($data as $k=>$v){
                $sql = "DELETE FROM " . $this->pre . "cart WHERE goods_id = '" . $v['goods_id'] . "'";
                $this->query($sql);
            }
        }