Prestashop cart empty - no product in cart

Prestashop cart empty - no product in cart

A real nightmare - customer adds products to the shopping cart, but the cart does not work. The product mysteriously disappears and there is just the annoying "Your shopping cart is empty" message at the prestashop checkout screen. Sure, the customer is guaranteed to disappear as well.

A real nightmare - customer adds products to the shopping cart, but the cart does not work. The product mysteriously disappears and there is just the annoying "Your shopping cart is empty" message at the prestashop checkout screen. Sure, the customer is guaranteed to disappear as well.

This is a cookie conflict problem, caused by setting/reading cookies from different subdomains, ussually www.yourdomain.com and yourdomain.com.

Rule 1. Make sure your customers will never get the wrong cookie. The 1.6 prestashop versions will make proper redirect to the main shop url before trying to set the cookie. Hovewer, this may not be the the case for some 1.5x versions (e.g see there) . When in doubts, force the redirect before the prestashop engine gets its chance to set or modify a cookie. To do this, you will need to edit the .htaccess file located in the eshop root directory. Assuming that the main shop url is www.mydomain.com, you will need to add these two lines just after the RewriteEngineOn line:

RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]

or even better duplicate the RewriteEngineOn line at the very beginning of the .htaccess and follow it by the two lines

 

Rule 2. Do not fetch content from different subdomain. Assume your website url is www.mydomain.com, and you use a module to embed image like this: (notice the missing www in the image src). This kind of problem is difficult to recognise, since it will affects only some customers, depending on their cookie history and used browsers. Surely, it is perfectly ok to serve static content from cookieless domains/subdomains.

 

Rule 3. After any major change (prestashop upgrade, webhoster change etc.), clean the browser cache and remove all cookies and offsite data related to your website. Make two complete orders, first one as a guest, second as a registered customer. Repeat the guest orders using other major browsers.

webdnes.cz
®2016