On checkout, when a customer enters a shipping address that is different from the billing address and error pops up stating:

SyntaxError: Unexpected token <

OK

Notice:Undefined variable: json_payment in /catalog/controller/checkout/address.php on line 169
Notice:Undefined variable: json_payment in /catalog/controller/checkout/address.php on line 171{"address":"xxxx
xxxx
xxxx
"}

The "xxxx" data returned is the customer ship to information entered in the form.

Lines 169 - 171 in the file are:

if ($json_payment && $json_shipping) {
$json['error'] = array_merge($json_payment['error'], $json_shipping['error']);
} elseif ($json_payment) {

This code is part of a larger if/else statement that starts on line 114, and I see where json_payment is supposed to be set:

if (isset($this->request->post['payment_address']) && $this->request->post['payment_address'] == 'existing') {
$this->load->model('account/address');

if (empty($this->request->post['payment_address_id'])) {
$json['error']['warning'] = $this->language->get('error_address');
} elseif (!in_array($this->request->post['payment_address_id'], array_keys($this->model_account_address->getAddresses()))) {
$json['error']['warning'] = $this->language->get('error_address');
}

if (!$json) {
// Default Payment Address
$this->load->model('account/address');

$this->session->data['payment_address'] = $this->model_account_address->getAddress($this->request->post['payment_address_id']);

unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
} else {
$json_payment = $this->validateFields('payment');

if (!$json_payment) {
$this->saveAddress('payment');
}
}

if (isset($this->request->post['shipping_address']) && $this->request->post['shipping_address'] == 'existing') {
$this->load->model('account/address');

if (empty($this->request->post['shipping_address_id'])) {
$json['error']['warning'] = $this->language->get('error_address');
} elseif (!in_array($this->request->post['shipping_address_id'], array_keys($this->model_account_address->getAddresses()))) {
$json['error']['warning'] = $this->language->get('error_address');
}

if (!$json) {
// Default Shipping Address
$this->load->model('account/address');

$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->request->post['shipping_address_id']);

unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);

$this->load->controller('checkout/shipping_method');
$this->load->controller('checkout/shipping_method/save');
}
} else {
$json_shipping = $this->validateFields('shipping');

if (!$json_shipping) {
$this->saveAddress('shipping');
}
}

if ($json_payment && $json_shipping) {
$json['error'] = array_merge($json_payment['error'], $json_shipping['error']);
} elseif ($json_payment) {
$json['error'] = $json_payment['error'];
} elseif ($json_shipping) {
$json['error'] = $json_shipping['error'];
}

}


Any suggestions on how to fix?
In General
Thursday, January 21 2016, 10:16 PM
Share this post:
Responses (4)
  • Accepted Answer

    Wednesday, April 18 2018, 03:18 PM - #Permalink
    As mentioned by Hermann, the solution is to turn of error display, as this isn't a real error, just a notification popping up.

    Look at 'Settings -> Server' tab: https://arastta.org/docs/user-manual/system/settings/server
    Display Errors: Whether to display the PHP errors, warnings and notices produced by your store. This should be set to "No" for a live store.


    I'm adding this because the tread starter hasn't followed up / marked it solved, and it has come to my attention that some has missed the solution in it.
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, November 20 2016, 10:07 PM - #Permalink
    Hi,

    I've the same error but only if you use advanced error reporting in admin settings. If you do so it open a java popup window (see annex).
    At error reporting I've got following error:
    PHP Notice: Undefined variable: json_shipping in /---/---/---/catalog/controller/checkout/address.php on line 173

    Kind regards

    Hermann
    Attachments:
    The reply is currently minimized Show
  • Accepted Answer

    Monday, January 25 2016, 08:33 AM - #Permalink
    Thanks for the response, Denis. This only occurs when the customer is logged in.
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, January 24 2016, 12:18 AM - #Permalink
    Loren, does this happen when customer is logged in or is being just registered or is guest?
    The reply is currently minimized Show
Your Reply