Post by knowtech » Fri Apr 05, 2019 7:16 pm

OC version 3.0.2.0

When I try to create an account on the checkout page with products in my cart I get an error like:

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

If I then press F5 the account will be created and I can go on with the order without problems.

This problem will not occur if the customer first creates the account and then places products in the cart and go to the checkout page.

Someone who has seen this and has some ideas?

Attachments

checkout.PNG

checkout.PNG (31.44 KiB) Viewed 2142 times


Newbie

Posts

Joined
Fri Jan 16, 2015 5:58 am

Post by letxobnav » Fri Apr 05, 2019 11:18 pm

well, the data you send to the JSON.parse function is not a valid json encoded string.
My guess is that is is due to the "where did you hear about us" add-on you have there, I bet you do not show that when a customer is already registered.
So maybe disable that add-on and test if you still have that error.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by knowtech » Thu Apr 18, 2019 4:30 pm

The problem is still there when i unistalled the "where did you hear about us" Extension

Newbie

Posts

Joined
Fri Jan 16, 2015 5:58 am

Post by letxobnav » Fri Apr 19, 2019 6:32 pm

well, then you need to trace it with chrome or firefox web developer.
turn that on, select the network tab and go thru the same sequence and check what the ajax calls like

index.php?route=checkout/checkout/country&country_id=xxx

return as json response strings.

something like:
{"country_id":"206","name":"Taiwan","iso_code_2":"TW","iso_code_3":"TWN","address_format":"","postcode_required":"0","zone":[{"zone_id":"3135","country_id":"206","name":"Chang-hua","code":"CH","status":"1"},{"zone_id":"3154","country_id":"206","name":"Chi-lung","code":"CL","status":"1"},{"zone_id":"3136","country_id":"206","name":"Chia-i","code":"CI","status":"1"},{"zone_id":"3153","country_id":"206","name":"Chia-i city","code":"CC","status":"1"},{"zone_id":"3155","country_id":"206","name":"Hsin-chu city","code":"HC","status":"1"},{"zone_id":"3137","country_id":"206","name":"Hsin-chu county","code":"HS","status":"1"},{"zone_id":"3138","country_id":"206","name":"Hua-lien","code":"HL","status":"1"},{"zone_id":"3139","country_id":"206","name":"I-lan","code":"IL","status":"1"},{"zone_id":"3158","country_id":"206","name":"Kao-hsiung city","code":"KC","status":"1"},{"zone_id":"3140","country_id":"206","name":"Kao-hsiung county","code":"KH","status":"1"},{"zone_id":"3141","country_id":"206","name":"Kin-men","code":"KM","status":"1"},{"zone_id":"3142","country_id":"206","name":"Lien-chiang","code":"LC","status":"1"},{"zone_id":"3143","country_id":"206","name":"Miao-li","code":"ML","status":"1"},{"zone_id":"3144","country_id":"206","name":"Nan-t'ou","code":"NT","status":"1"},{"zone_id":"3145","country_id":"206","name":"P'eng-hu","code":"PH","status":"1"},{"zone_id":"3146","country_id":"206","name":"P'ing-tung","code":"PT","status":"1"},{"zone_id":"3156","country_id":"206","name":"T'ai-chung","code":"TH","status":"1"},{"zone_id":"3147","country_id":"206","name":"T'ai-chung","code":"TG","status":"1"},{"zone_id":"3148","country_id":"206","name":"T'ai-nan","code":"TA","status":"1"},{"zone_id":"3157","country_id":"206","name":"T'ai-nan","code":"TN","status":"1"},{"zone_id":"3159","country_id":"206","name":"T'ai-pei city","code":"TC","status":"1"},{"zone_id":"3149","country_id":"206","name":"T'ai-pei county","code":"TP","status":"1"},{"zone_id":"3150","country_id":"206","name":"T'ai-tung","code":"TT","status":"1"},{"zone_id":"3151","country_id":"206","name":"T'ao-yuan","code":"TY","status":"1"},{"zone_id":"3152","country_id":"206","name":"Yun-lin","code":"YL","status":"1"}],"status":"1"}

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by knowtech » Fri May 24, 2019 11:14 pm

I found out this...

/catalog/controller/checkout/register.php:246

$this->response->setOutput(json_encode($json));

The code abow sends a junk character when $json is empty. the character is: \ufeff and that cause the error.

How do I get rid of it?

I'm not a programmer :)

Newbie

Posts

Joined
Fri Jan 16, 2015 5:58 am

Post by letxobnav » Fri May 24, 2019 11:22 pm

looks like a UTF-16 BOM character.
So you have an encoding issue there.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by knowtech » Fri May 24, 2019 11:39 pm

Can you give me a hint on how to fix it?

Original the code look like this:
$this->response->addHeader('Content-type: application/json; charset=utf-8');
$this->response->setOutput(json_encode($json));

Newbie

Posts

Joined
Fri Jan 16, 2015 5:58 am

Post by letxobnav » Sat May 25, 2019 12:14 am

could be that you saved some of your language files with BOM encoding.
Check those files are saved as UTF-8 and not UTF-8-BOM or UTF-16-BOM

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: No registered users and 92 guests