Jump to content

error message - Impossible to add products to cart


Recommended Posts

The error means that the Javascript retrieving cart information from Prestashop ran into issues parsing the response that came back from the server. This could be for any number of reasons - your browser is doing something funny, there is product data with unescaped characters causing problems, something messed up with the JSON generation code on the server, extra text getting prepended or appended to the output, etc.

The first thing I would suggest is that you disable Javascript in your browser temporarily and see if you can add products normally. If that works fine, then the issue has got to be related to Javascript either on your machine or in the output coming back from the server.

You can manually inspect what is being sent by calling the cart directly by calling the cart directly. If you view the source to your product page you will find a section like this:

<input type="hidden" name="token" value="00757d49336c884062383c23" />
<input type="hidden" name="id_product" value="1" id="product_page_product_id" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="id_product_attribute" id="idCombination" value="" />



Plug your token and id_product values in to the following URL:

http://www.prestashop.com/demo/cart.php?add&ajax=true&qty=1&id_product=1&token=00757d49336c884062383c23

You would replace everything up to "cart.php" with the URL to your shop, your product id instead of "1" and your token value instead of "00757d49336c884062383c23". If you access this URL in your browser, you should be given some text representing a JSON object (Javascript representing your cart contents) which should look something like this:

{
'products': [
   {
       'id':            2,
       'link':          'http://www.prestashop.com/demo/music-ipods/2-ipod-shuffle.html',
       'quantity':      2,
       'priceByLine':   '158,00 €',
       'name':          'iPod shuffle',
       'price':         '158,00 €',
       'idCombination': 8,
       'hasAttributes': true,
       'attributes':    'Green',
       'hasCustomizedDatas': false,

       'customizedDatas':[
               ]


   },
   {
       'id':            1,
       'link':          'http://www.prestashop.com/demo/music-ipods/1-ipod-nano.html',
       'quantity':      4,
       'priceByLine':   '756,20 €',
       'name':          'iPod Nano',
       'price':         '756,20 €',
       'idCombination': 31,
       'hasAttributes': true,
       'attributes':    'Black, 16Go',
       'hasCustomizedDatas': false,

       'customizedDatas':[
               ]


   },
],

'discounts': [
],

'shippingCost': '0,00 €',
'wrappingCost': '0,00 €',
'nbTotalProducts': '6',
'total': '914,20 €',
'productTotal': '914,20 €',

'hasError' : false

}



My guesses here are:

1. there will be an error message or extraneous HTML embedded in the array returned making it unparseable (track down the source of the error)

2. a product has text in it that is breaking the array due to lack of proper escaping (change the product details)

3. your browser has a taskbar or something similar installed that is messing with its Javascript behaviour

Cheers

Link to comment
Share on other sites

There is also a problem in which i found that if you don't have a default carrier setup in presta back end you will also get that problem with parse error and when you click view cart you get a hack attempt error. maybe this will help?
cheers

Link to comment
Share on other sites

  • 1 month later...

I've found the solution!)) Thanks you very much, codegrunt!
I've tried to enter url in browser as you told: "cart.php?add&ajax=true&qty=1&id_product=1&token=c111e173641a40c51b739ca280ac2fe7". And I've found the reason: there was a mysql warning (my "display_errors" in config.inc.php had been turned to "on") like

Warning: Unknown: 1 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0


in the end of json response cart.php returned.
I've just turned display_errors to "off" and everything works fine!

Does anybody know how to remove this warning at all, even if display_errors turned on?

Link to comment
Share on other sites

  • 4 years later...

the very first idea is actually a plastic animal mug that will come in a variety of themes elephant

 

Halloween fun over time could involve pranks such as strewing toilet paper around tree divisions, painting graffiti in items together with aerosol shaving cream, doll tricks that pop up once the tricker shakes fingers with the treater, for example buzzers or coils. The pranks or techniques were relatively harmless, however in many places abroad, many Halloween things to do are totally banned. Enjoyable for Hallow's eve also includes haunted houses, parties having games and also refreshments which sport trick or treat costumes and either an autumn or haunted theme..

 

You can find plus-sized dresses for female in a wide variety online unlike the past in which the clothes began in limited quantity not to mention that these people were very costly without necessarily trendy. Therefore, i thought this was a major problem in which plus sized females who were in a position to become modern experienced. Now, all these issues have been fixed and plus sized women can certainly dress fashionably like any body else.

 

 

http://www.lokalaw.com/html/Tom_and_Jerry_Mascot_Costumes.html

http://w2w-business.de/html/Mengniu_Charaters_Mascot_Costumes.html

http://hahoplay.com/html/Denver_Broncos_football_jerseys.html

http://www.nazaret.cz/html/cheap_Russell_Wilson_jersey1.html

http://aoshidianka.net/html/Seattle_Seahawks_jersey1.html

http://twspd.com/html/Seattle_Seahawks_jersey1.html

http://www.wipwar.com/html/nike_Eric_Decker_jersey.html

http://vabenesh.com/html/Welker_jerseys2.html

http://www.erleinsbacher.de/html/Diamond_Costumes.html

Link to comment
Share on other sites

×
×
  • Create New...