Jump to content

Impossible To Add Product To Cart Error Prestashop Ajax


phingko

Recommended Posts

My website is working fine until this early week, whenever customers try to add a product, it will come out with this error;
 

Impossible to add the product to the cart.
textStatus: 'parsererror'
errorThrown: 'SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 3 of the JSON data'
responseText:
45b
{ "products": [ .....} 0

But if I put https://www.domain.com.au instead of www.domain.com.au, the AJAX won't throw any error.

There are few speculations I have here, but I have no solutions; what I can think of that there is whitespace I need to delete, but I don't know where. And that the code that I put into my blockcart.php caused it;
 

global $smarty;
$smarty->assign('customerDefaultGroup' , Customer::getDefaultGroupId(Context::getContext()->customer->id));



But I tried to comment those out, it still throws me error. SO for now, I disabled the AJAX but customers has started to complain that they are directed to shopping cart every time they add product.
And I don't know if this is related, I have random chars on my header every time I access the website.
Help

Edited by phingko (see edit history)
Link to comment
Share on other sites

Hi presto, thank you for the reply.

 

I managed to direct my homepage to https://www.domain.com.au, but the rest of the page remains as www.domain.com.au

 

And I just realized the error thrown by Firefox and Chrome are different. In Chrome the error is

Impossible to add the product to the cart. 
textStatus: 'parsererror' 
errorThrown: 'SyntaxError: 'Unexpected token c' 
responseText: 
9ce

The responseText are not always the same though. It will throw this random numbers and chars and the alphabet will be picked up as 'unexpected token'

 

Anyone face this problem before?

I don't use paypal on my website and I have deactivated google analytic as other posts suggested but none works.

Edited by phingko (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...