Jump to content

[SOLVED] Bug Prestashop 1.4.x. AJAX cart emptied sometimes when moving to another page


Recommended Posts

Folks,

 

I've spent a good amount of time today debugging the following issue that one of the online shops I manage (http://www.ociohogar.com) was suffering. So I thought I would share the issue and the solution.

 

I've seen similar issues reported several times but anyway I have raised a new Jira issue for Prestashop team with the description of the issue, root cause and the fix I have done for my shop. Issue details below:

 

http://forge.prestas...owse/PSCFI-6806

 

The issue was the following:

1. Someone adds a product to the cart. Previously to the addition the cart is collapsed.

2. After pressing "Add to cart" you could see AJAX animiation perfectly working, the product added to the cart and also from BO->Customers->Carts you could see the new cart.

3. However when from the FO you confirm the cart or just move to another page the cart was emptied at the FO.

 

I know this was happening to some customers in this shop since around April because they complaint but it was happening rarely I was not ever able to reproduce it either in the production site or any of the development sites before. However around 1 month ago we've done quite a few changes for performance improvements to get a better TTFB and page load time and this seems to have caused race conditions changes in AJAX queries that was making this issue happening almost every time that someone would add a product to the cart and this was collapsed.

 

In the bug report I give full details of the issue but in summary the root cause is that the cookie was overwritten by one of the two AJAX queries that run in paralllel overwritting the good data about id_cart that had been previously received on the other query.

 

This issue can potentially happen in any Prestashop 1.4 setup, it depends on racing coinditions between two AJAX Queries giong on in parallel when cart is collapsed and someone adds to the cart. It is quite annoying to the customer and I know this shop has lost quite a few orders due to this issue.

 

I haven't looked at whether there have been changes or not in this area in Prestashop 1.5 or later versions so I don't know if the issue and fix is applicable to that release.

 

I give some details of the fix I have done in Jira/bug report. If someone is interested in getting the very specific changes I have done let me know.

 

The changes are very simple and safe.

 

Best Regards

Share this post


Link to post
Share on other sites

 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More