码迷,mamicode.com
首页 > 其他好文 > 详细

ecshop 收货地址处理,默认,删除

时间:2015-11-27 12:53:28      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

设置位置:ecs_users标的   country字段,默认是0,默认地址是 users_address 的address_id

 

设置默认收货地址

/**
 * 设置默认地址
 *
 * @access  public
 * @param   integer $id 收货地址id
 * @return  boolean
 */
function set_default_addr($id)
{

    $uid = $_SESSION[user_id];
    $sql = "UPDATE " .$GLOBALS[ecs]->table(users) . " SET address_id = ‘$id‘ WHERE user_id = ‘$uid‘";
    $res = $GLOBALS[db]->query($sql);

    return $res;
}

删除收货地址

/**
 * 删除一个收货地址
 *
 * @access  public
 * @param   integer $id
 * @return  boolean
 */
function drop_consignee($id)
{
    $sql = "SELECT user_id FROM " .$GLOBALS[ecs]->table(user_address) . " WHERE address_id = ‘$id‘";
    $uid = $GLOBALS[db]->getOne($sql);

    if ($uid != $_SESSION[user_id])
    {
        return false;
    }
    else
    {
        $sql = "DELETE FROM " .$GLOBALS[ecs]->table(user_address) . " WHERE address_id = ‘$id‘";
        $res = $GLOBALS[db]->query($sql);

        return $res;
    }
}

 取得收货地址列表

/**
     * 取得收货人地址列表
     * @param   int     $user_id    用户编号
     * @param   int     $id         收货地址id
     * @return  array
     */
    function get_consignee_list($user_id, $id = 0, $num = 10, $start = 0) {
        if ($id) {
            $where[address_id] = $id;
            $this->table = user_address;
            return $this->find($where);
        } else {
            $sql = select * from  . $this->pre . user_address where user_id =  . $user_id .  order by address_id limit  . $start . ,  . $num;
            return $this->query($sql);
        }
    }

 查询默认user地址

public function select_default_address(){
        $user_id =$_SESSION[user_id];
        
        $info  = M()->query("SELECT address_id FROM " .$this->model->pre. "users WHERE user_id=‘$user_id‘");
        print_r($info[0][‘address_id‘]);
    }

 

设置收货默认地址

public function set_default_address(){
        $id = $_GET[address_id];
        $userid = $_SESSION[user_id];
          $sql = "UPDATE " .$this->model->pre. "users SET address_id = ‘$id‘ WHERE user_id = ‘$userid‘";
          $res = M()->query($sql);

        show_message(设置成功, $_LANG[address_list_lnk], U(user/address_list));
    }

 

ecshop 收货地址处理,默认,删除

标签:

原文地址:http://www.cnblogs.com/wesky/p/4999900.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!