简体   繁体   中英

opencart 2.0 confirm.php getZone Notice: Undefined index: name

if (isset($this->session->data['guest']['payment']['zone_id'])) {
            $data['zone_id'] = $this->session->data['guest']['payment']['zone_id'];         
        } else {
            $data['zone_id'] = '';
        }
        $this->load->model('localisation/zone');

        $zone_info = $this->model_localisation_zone->getZone($data['zone_id']);

        $data['zone'] = $zone_info['name'];

I get the data in this way, but fails Notice: Undefined index: name I work file catalog/controller/checkout/confirm.php Please help me.

Try This

if(isset($this->session->data['payment_address']['zone'])){
  $data['zone'] = $this->session->data['payment_address']['zone'];
}else{
  $data['zone'] = '';
}

Check $data['zone_id'] is receiving some value or not

echo "< pre>"; print_r($data['zone_id']);die;

if $data['zone_id'] is empty then check this $this->session->data['guest']['payment']['zone_id'];

or

if $data['zone_id'] is receiving value then add this

if (isset($this->session->data['guest']['payment']['zone_id'])) {
            $data['zone_id'] = $this->session->data['guest']['payment']['zone_id'];         
        } else {
            $data['zone_id'] = '';
        }
        $this->load->model('localisation/zone');

        $zone_info = $this->model_localisation_zone->getZone($data['zone_id']);

$zone_info['name'] = isset($zone_info['name'])?$zone_info['name']:'';

        $data['zone'] = $zone_info['name'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM