Error Unexpected token < in JSON at position 0. How to solve?

5c9a285e07643010799702.png

Clicking the check checkout without registration, should reach the fields and after clicking on the continue button POPs up this error.

Code guest.php
<?php
class ControllerCheckoutGuest extends Controller {
 public function index() {
$this->load->language('checkout/checkout');

 $data['text_select'] = $this->language->get('text_select');
 $data['text_none'] = $this->language->get('text_none');
 $data['text_your_details'] = $this->language->get('text_your_details');
 $data['text_your_account'] = $this->language->get('text_your_account');
 $data['text_your_address'] = $this->language->get('text_your_address');
 $data['text_loading'] = $this->language->get('text_loading');

 $data['entry_firstname'] = $this->language->get('entry_firstname');
 $data['entry_lastname'] = $this->language->get('entry_lastname');
 $data['entry_email'] = $this->language->get('entry_email');
 $data['entry_telephone'] = $this->language->get('entry_telephone');
 $data['entry_fax'] = $this->language->get('entry_fax');
 $data['entry_company'] = $this->language->get('entry_company');
 $data['entry_customer_group'] = $this->language->get('entry_customer_group');
 $data['entry_address_1'] = $this->language->get('entry_address_1');
 $data['entry_address_2'] = $this->language->get('entry_address_2');
 $data['entry_postcode'] = $this->language->get('entry_postcode');
 $data['entry_city'] = $this->language->get('entry_city');
 $data['entry_country'] = $this->language->get('entry_country');
 $data['entry_zone'] = $this->language->get('entry_zone');
 $data['entry_shipping'] = $this->language->get('entry_shipping');

 $data['button_continue'] = $this->language->get('button_continue');
 $data['button_upload'] = $this->language->get('button_upload');

 $data['customer_groups'] = array();

 if (is_array($this->config->get('config_customer_group_display'))) {
$this->load->model('account/customer_group');

 $customer_groups = $this->model_account_customer_group->getCustomerGroups();

 foreach ($customer_groups as $customer_group) {
 if (in_array($customer_group['customer_group_id'], $this->config->get('config_customer_group_display'))) {
 $data['customer_groups'][] = $customer_group;
}
}
}


 if (isset($this->request->post['customer_group_id'])) {
 $data['customer_group_id'] = $this->request->post['customer_group_id'];
 } elseif(isset($this->session->data['guest']['customer_group_id'])) {


 $data['customer_group_id'] = $this->session->data['guest']['customer_group_id'];
 } else {
 $data['customer_group_id'] = $this->config->get('config_customer_group_id');
}
//start lightshop
 $data['button_back'] = $this->language->get('button_back');
 $data['entry_telephone'] = $this->language->get('entry_telephone');
 $data['entry_email'] = $this->language->get('entry_email');
 $data['checkout_st3_sa'] = $this->config->get('theme_lightshop_checkout_st3_sa');

$this->load->model('catalog/lightshop');
 $activeFields = $this->model_catalog_lightshop->getFields($data['customer_group_id']);
 $allFields = $this->model_catalog_lightshop->getAllFields();

 $data['allCustomFields'] = $allFields;
 foreach($allFields as $field){
 $data['entry_'.$field.'_required'] = 0;
 $data['entry_'.$field.'_show'] = 0;

 if (isset($this->request->post[$field])) {
 $data[$field] = $this->request->post[$field];
 } elseif (!empty($customer_info)) {
 $data[$field] = $customer_info[$field];
 } else {
 $data[$field] = ";
}

 if (isset($this->error[$field])) {
 $data['error_'.$field] = $this->error[$field];
 } else {
 $data['error_'.$field] = ";
}

}

 foreach($activeFields as $field){
if($field['description']){
 $data['entry_'.$field['name']] = $field['description'];
}
 $data['entry_'.$field['name'].'_required'] = $field['required'];
 $data['entry_'.$field['name'].'_show'] = $field['is_show'];
}
//lightshop end
 if (isset($this->session->data['guest']['firstname'])) {
 $data['firstname'] = $this->session->data['guest']['firstname'];
 } else {
 $data['firstname'] = ";
}

 if (isset($this->session->data['guest']['lastname'])) {
 $data['lastname'] = $this->session->data['guest']['lastname'];
 } else {
 $data['lastname'] = ";
}

 if (isset($this->session->data['guest']['email'])) {
 $data['email'] = $this->session->data['guest']['email'];
 } else {
 $data['email'] = ";
}

 if (isset($this->session->data['guest']['telephone'])) {
 $data['telephone'] = $this->session->data['guest']['telephone'];
 } else {
 $data['telephone'] = ";
}

 if (isset($this->session->data['guest']['fax'])) {
 $data['fax'] = $this->session->data['guest']['fax'];
 } else {
 $data['fax'] = ";
}

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

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

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

 if (isset($this->session->data['payment_address']['postcode'])) {
 $data['postcode'] = $this->session->data['payment_address']['postcode'];
 } elseif (isset($this->session->data['shipping_address']['postcode'])) {
 $data['postcode'] = $this->session->data['shipping_address']['postcode'];
 } else {
 $data['postcode'] = ";
}

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

 if (isset($this->session->data['payment_address']['country_id'])) {
 $data['country_id'] = $this->session->data['payment_address']['country_id'];
 } elseif (isset($this->session->data['shipping_address']['country_id'])) {
 $data['country_id'] = $this->session->data['shipping_address']['country_id'];
 } else {
 $data['country_id'] = $this->config->get('config_country_id');
}

 if (isset($this->session->data['payment_address']['zone_id'])) {
 $data['zone_id'] = $this->session->data['payment_address']['zone_id'];
 } elseif (isset($this->session->data['shipping_address']['zone_id'])) {
 $data['zone_id'] = $this->session->data['shipping_address']['zone_id'];
 } else {
 $data['zone_id'] = ";
}

$this->load->model('localisation/country');

 $data['countries'] = $this->model_localisation_country->getCountries();

 // Custom Fields
$this->load->model('account/custom_field');

 $data['custom_fields'] = $this->model_account_custom_field->getCustomFields();

 if (isset($this->session->data['guest']['custom_field'])) {
 if (isset($this->session->data['guest']['custom_field'])) {
 $guest_custom_field = $this->session->data['guest']['custom_field'];
 } else {
 $guest_custom_field = array();
}

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

 $data['guest_custom_field'] = $guest_custom_field + $address_custom_field;
 } else {
 $data['guest_custom_field'] = array();
}

 $data['shipping_required'] = $this->cart->hasShipping();

 if (isset($this->session->data['guest']['shipping_address'])) {
 $data['shipping_address'] = $this->session->data['guest']['shipping_address'];
 } else {
 $data['shipping_address'] = true;
}

 // Captcha
 if ($this->config->get($this->config->get('config_captcha') . '_status') && in_array('guest', (array)$this->config->get('config_captcha_page'))) {
 $data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha'));
 } else {
 $data['captcha'] = ";
}

 $this->response->setOutput($this->load->view('checkout/guest', $data));
}

 public function save() {
$this->load->language('checkout/checkout');

 $json = array();

 // Validate if customer is logged in.
 if ($this->customer->isLogged()) {
 $json['redirect'] = $this->url->link('checkout/checkout', ", true);
}

 // Validate cart has products and has stock.
 if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {
 $json['redirect'] = $this->url->link('checkout/cart');
 }
March 19th 20 at 08:40
1 answer
March 19th 20 at 08:42
it says undefined variable customer_group_id on line 322

JSON is not being,just the server returns HTML instead of JSON, because the error on the server side and the error in the response body
@jorge.Fahey, Here's the error now claims to be.

<b>Notice</b>: Undefined index: firstname in <b>/home/buffalob/public_html/system/storage/modification/catalog/controller/checkout/guest.php</b> on line <b>244</b><b>Notice</b>: Undefined index: lastname in <b>/home/buffalob/public_html/system/storage/modification/catalog/controller/checkout/guest.php</b> on line <b>248</b><b>Notice</b>: Undefined index: email in <b>/home/buffalob/public_html/system/storage/modification/catalog/controller/checkout/guest.php</b> on line <b>252</b><b>Notice</b>: Undefined index: email in <b>/home/buffalob/public_html/system/storage/modification/catalog/controller/checkout/guest.php</b> on line <b>252</b><b>Notice</b>: Undefined index: telephone in <b>/home/buffalob/public_html/system/storage/modification/catalog/controller/checkout/guest.php</b> on line <b>256</b><b>Notice</b>: Undefined index: address_1 in <b>/home/buffalob/public_html/system/storage/modification/catalog/controller/checkout/guest.php</b> on line <b>260</b><b>Notice</b>: Undefined index: city in <b>/home/buffalob/public_html/system/storage/modification/catalog/controller/checkout/guest.php</b> on line <b>264</b><b>Notice</b>: Undefined index: country_id in <b>/home/buffalob/public_html/system/storage/modification/catalog/controller/checkout/guest.php</b> on line <b>270</b><b>Notice</b>: Undefined index: country_id in <b>/home/buffalob/public_html/system/storage/modification/catalog/controller/checkout/guest.php</b> on line <b>276</b>{"error":{"firstname":"\u0418\u043c\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0442 1 \u0434\u043e 32 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432!","lastname":"\u0424\u0430\u043c\u0438\u043b\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0442 1 \u0434\u043e 32 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432!"}}
- alana49 commented on March 19th 20 at 08:45
@alana49, it's great - jorge.Fahey commented on March 19th 20 at 08:48

Find more questions by tags JSONPHP