Page 1 of 3

checkout page json erorrs

Posted: Tue May 03, 2016 9:40 pm
by johnyonutz
when checking out i keep getting:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: comment in ...
for each step - invoice, delivery form

Re: checkout page json erorrs

Posted: Tue May 03, 2016 11:39 pm
by viethemes
Are you using extension to replace the built-in checkout?

Re: checkout page json erorrs

Posted: Tue May 03, 2016 11:47 pm
by johnyonutz
default theme with no extensions

Re: checkout page json erorrs

Posted: Wed May 04, 2016 4:22 am
by straightlight
More information would be needed here.

- Which OC version are you using?
- Does this error occur by using the API from the admin orders or from the customer's checkout page?

What I am noticing is this error from your first post:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: comment in ...
"Comment in ..." (...) where exactly? A location should be provided from the error window.

Re: checkout page json erorrs

Posted: Wed May 04, 2016 2:29 pm
by johnyonutz
version is 2.2.0.0

the errors appear when trying to place an order as a client

errors:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: fax in <b>/home/imecamc/public_html/catalog/controller/checkout/guest.php</b> on line <b>273</b>[]
then if i complete fax i get:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: comment in <b>/home/imecamc/public_html/catalog/controller/checkout/shipping_method.php</b> on line <b>127</b>[]
and the errors appear if i do not complete each and every field in the order - even the order comment form....

Re: checkout page json erorrs

Posted: Wed May 04, 2016 7:20 pm
by straightlight
While the fax is not a mandatory field, it may need to be modified.

In catalog/controller/checkout/guest.php file,

find:

Code: Select all

$this->session->data['guest']['fax'] = $this->request->post['fax'];
replace with:

Code: Select all

$this->session->data['guest']['fax'] = '';

if (!empty($this->request->post['fax'])) {
    $this->session->data['guest']['fax'] = $this->request->post['fax'];
}
In catalog/controller/checkout/shipping_method.php file,

find:

Code: Select all

$this->session->data['comment'] = strip_tags($this->request->post['comment']);
replace with:

Code: Select all

$this->session->data['comment'] = '';

if (!empty($this->request->post['comment'])) {
    $this->session->data['comment'] = strip_tags($this->request->post['comment']);
}

Re: checkout page json erorrs

Posted: Tue May 10, 2016 12:24 am
by johnyonutz
hi, and thanks for helping me!

i tried this and i get a lot of messages...

and it seems that it is the same if i order without guest mode..

Re: checkout page json erorrs

Posted: Tue May 10, 2016 5:04 pm
by johnyonutz
i also have error on payment and shipping...

Re: checkout page json erorrs

Posted: Tue May 10, 2016 10:12 pm
by straightlight
In catalog/controller/checkout/guest.php file,

find:

Code: Select all

$this->session->data['payment_address']['company'] = $this->request->post['company'];
replace with:

Code: Select all

$this->session->data['payment_address']['company'] = '';

if (!empty($this->request->post['company'])) {
    $this->session->data['payment_address']['company'] = $this->request->post['company'];
}
Then, find:

Code: Select all

$this->session->data['payment_address']['address_2'] = $this->request->post['address_2'];
replace with:

Code: Select all

$this->session->data['payment_address']['address_2'] = '';

if (!empty($this->request->post['address_2'])) {
    $this->session->data['payment_address']['address_2'] = $this->request->post['address_2'];
}

Re: checkout page json erorrs

Posted: Wed May 11, 2016 3:22 pm
by johnyonutz
thank straightlight

i allready followed your example and it works fine

however i am stuck with the payment and shipping method...

the same error is thrown for guest and account mode...

Re: checkout page json erorrs

Posted: Fri May 13, 2016 1:15 am
by straightlight
In catalog/controller/checkout/payment_method.php and catalog/controller/checkout/shipping_method.php file,

find:

Code: Select all

$this->session->data['comment'] = strip_tags($this->request->post['comment']);
replace both with:

Code: Select all

$this->session->data['comment'] = '';

if (!empty($this->request->post['comment'])) {
	$this->session->data['comment'] = $this->request->post['comment'];
}

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 12:06 am
by platypuspuzzles
Hi

I have this same issue, and thanks to the above posts, I was able to fix all but one JSON error

I've updated onto a copy of my store and the upgrade script worked like a charm from 2.0.3.1 to 2.2.0.0

I had this same error for guest.php and shipping_method.php but was able to find the fix on the forum.

I haven't been able to find a fix for this one though:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: comment in <b>/.../catalog/controller/checkout/payment_method.php</b> on line <b>186</b>[]
Any help greatly appreciated

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 12:07 am
by straightlight
platypuspuzzles wrote:Hi

I have this same issue, and thanks to the above posts, I was able to fix all but one JSON error

I've updated onto a copy of my store and the upgrade script worked like a charm from 2.0.3.1 to 2.2.0.0

I had this same error for guest.php and shipping_method.php but was able to find the fix on the forum.

I haven't been able to find a fix for this one though:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: comment in <b>/.../catalog/controller/checkout/payment_method.php</b> on line <b>186</b>[]

Any help greatly appreciated
The solution is right above your post for this file particularly ...

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 12:37 am
by platypuspuzzles
straightlight wrote:
platypuspuzzles wrote:Hi

I have this same issue, and thanks to the above posts, I was able to fix all but one JSON error

I've updated onto a copy of my store and the upgrade script worked like a charm from 2.0.3.1 to 2.2.0.0

I had this same error for guest.php and shipping_method.php but was able to find the fix on the forum.

I haven't been able to find a fix for this one though:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: comment in <b>/.../catalog/controller/checkout/payment_method.php</b> on line <b>186</b>[]

Any help greatly appreciated
The solution is right above your post for this file particularly ...
I tried to find and replace the text in payment_method too, but it didnt work

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 12:47 am
by platypuspuzzles
I tell a lie - it did work! (Thanks, I must have made a mistake when attempting the edit the first time)

Now I have a new error
Notice: Error: Could not load template /.../catalog/view/theme/default/template/default/template/payment/nabtrans.tpl! in /.../vqmod/vqcache/vq2-system_library_template_basic.php on line 26
I'll post this on the nab transact extention comments

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 12:51 am
by straightlight
Nabtrans Payment Gateway is a contributed extension as it is not part of the core. Contact the payment gateway developer of that extension to resolved this issue.

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 3:14 pm
by platypuspuzzles
I've just completed testing the rest of the different checkout processes to trigger the JSON errors (I only have default/no wholesale account log in so haven't tested different account type log ins)
The following checkout processes produce these errors - I've tried making changes, to the above suggestions, and editing shipping/payment address , but I receive internal error message, and not sure what causes it.

Any help to let me know what to replace the associated lines with, greatly appreciated

**LOGGED IN ACCOUNT CHANGE OF ADDRESS**
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: company in <b>/home/.../catalog/model/account/address.php</b> on line <b>4</b>
<b>Notice</b>: Undefined index: address_2 in <b>/home/.../catalog/model/account/address.php</b> on line <b>4</b>[]
**REGISTER NEW ACCOUNT**
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: fax in <b>/home/.../catalog/model/account/customer.php</b> on line <b>14</b>
<b>Notice</b>: Undefined index: company in <b>/home/.../catalog/model/account/customer.php</b> on line <b>18</b>
<b>Notice</b>: Undefined index: address_2 in <b>/home/.../catalog/model/account/customer.php</b> on line <b>18</b>[]
**GUEST ACCOUNT**
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: company in <b>/home/.../catalog/controller/checkout/guest.php</b> on line <b>338</b>
<b>Notice</b>: Undefined index: address_2 in <b>/home/.../catalog/controller/checkout/guest.php</b> on line <b>340</b>[]

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 4:54 pm
by platypuspuzzles
**GUEST ACCOUNT - CHANGE DELIVERY ADDRESS**
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: company in <b>/home/.../catalog/controller/checkout/guest_shipping.php</b> on line <b>165</b>
<b>Notice</b>: Undefined index: address_2 in <b>/home/.../catalog/controller/checkout/guest_shipping.php</b> on line <b>167</b>[]
I made these edits: same again for address_2 - THIS FIXED THE ABOVE ERROR
replaced this

Code: Select all

$this->session->data['shipping_address']['company'] = $this->request->post['company'];

}
with

Code: Select all

$this->session->data['shipping_address']['company'] = '';

    if (!empty($this->request->post['company'])) {
        $this->session->data['shipping_address']['company'] = $this->request->post['company'];
}

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 7:06 pm
by straightlight
platypuspuzzles wrote:**GUEST ACCOUNT - CHANGE DELIVERY ADDRESS**

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

OK

<b>Notice</b>: Undefined index: company in <b>/home/.../catalog/controller/checkout/guest_shipping.php</b> on line <b>165</b>
<b>Notice</b>: Undefined index: address_2 in <b>/home/.../catalog/controller/checkout/guest_shipping.php</b> on line <b>167</b>[]

I made these edits: same again for address_2 - THIS FIXED THE ABOVE ERROR
replaced this

Code: Select all

$this->session->data['shipping_address']['company'] = $this->request->post['company'];
with

Code: Select all

$this->session->data['shipping_address']['company'] = '';

    if (!empty($this->request->post['company'])) {
        $this->session->data['shipping_address']['company'] = $this->request->post['company'];

This code change will create an missing } ending.

Code: Select all

}
Then, on the same file, find:

Code: Select all

$this->session->data['shipping_address']['address_2'] = $this->request->post['address_2'];
replace with:

Code: Select all

$this->session->data['shipping_address']['address_2'] = '';
			
			if (!empty($this->request->post['address_2'])) {
				$this->session->data['shipping_address']['address_2'] = $this->request->post['address_2'];
			}
at the end of your change. ;D

Re: checkout page json erorrs

Posted: Mon Jun 27, 2016 7:40 pm
by platypuspuzzles
oh cheers!

Do I use the same coding for all the above errors?