Jump to content

After add to cart, cart is empty


sini

Recommended Posts

Dear, I have got problem,

 on some computers (I have only one PC where this error is - Win10 home 32bit, Firefox 56.0.2 (32 bit)) after click add to cart button, Presta shows me that product was added to cart, after click on cart, cart is empty. 

 I have no other computer where it do the same, on this computer in IE and in Chrome it works well. I had call from customer that she can't add products to cart, so it isn't only this PC.

 PrestaShop 1.6.0.9

I tried: 
- turn off ccc
- empty cache
- turn off ajax cart
nothing made any changes :-(

In firefox i had, in console are these errors - see attachment.

 

Screen Shot 2017-10-30 at 12.22.12.png

Link to comment
Share on other sites

I found these two possible causes:
 

1. ID_CART number problem (I haven't this problem) - 

2. COOKIES www and non-www problem (it's my problem!) - 

 

So questions are: how to disable in presta to make non-www cookies? How to delete existing non-www cookies?

 

 

  • Like 1
Link to comment
Share on other sites

No One with same problem? 
At the moment I changed name of cookie in /classes/Cookie.php and It looks like it works.

form
this->_name = 'PrestaShop-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain);

to
this->_name = 'PrestaShop1-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain);

 

  • Like 3
Link to comment
Share on other sites

  • 8 months later...

I have same/simillar problem with presta 1.7.4.

Neither cleaning cache didn't help nor manual removal of cookies worked. 

Thank you for posting solution - renaming cookie did it for me too.


 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

If I got this wrong, and until I found a backup, this happened
Fatal error: Class 'Cookie' not found in /home/veganlin/public_html/x/config/config.inc.php on line 174
using PS 1.6 on Chrome and Opera using a windows 10 laptop 
Oddly, the error continued after i thought I'd changed the PHP code exactly back

When I tried a second time with a bit of cutting and pasting, the site worked but I still got

"your shopping cart is empty".

Thanks for the idea though.

Link to comment
Share on other sites

Hello John, we had clients with similar problems. There are several things that can cause this problem:

1. Your cookie have duplicates as you mentioned (www vs non-www).  This can hapen if you do not have propper redirect. For example, client came to your store as mystore.com (first cookie is created), then your configuration redirects user to www version (creation of second cookie occur). Keep in mind that cookies from non-www domain are available across all subdomains, including www. Solution for this case is quite simple, in cookie class, override function that sets cookie, set non-www domain cookie along with www, but for troubled domain, set cookie to expire somewhere in the past

2. Other cookie problem, that manifest itself with empty cart along with login problem (user cannot be loged in, always is redirected back) is problem with cookie size (max size is about 4096 bytes). After some research, we have decrypted clients problematic cookie, and found out that module responsible for this mess is actually "blockviewed". If someone is interested, we could create module that creates overrides for those functions. Hope this helps to understand the problematic behaviour

  • Thanks 1
Link to comment
Share on other sites

Thanks for help.
By fluke, I found my solution:
https://www.prestashop.com/forums/topic/263900-cart-is-empty-when-check-out/#comment-2938762
... if I turned geolocation on and off again, the cart cookie worked and thumbnail pictures transferred to the shopping cat.

I wish there were a better way of sorting all these threads and solutions. These are my notes made before I found my particular answer:

Google.co.uk/search?q=Prestashop+forum+"your+shopping+cart+is+empty”

prestashop.com/forums/topic/500027-your-shopping-cart-is-empty/ Papermarks thread, January 16
- debug mode. He sometimes get an extra error. I don’t.

- turn Friendly URLS off and on again. I did. 
- if I did get an error, someone suggests a page headed with that error, on which someone links to this:
in class FrontController i change (l.253) :

//'content_dir' => $protocol_content.Tools::getServerName().__PS_BASE_URI__,
'content_dir' => $protocol_content.(($useSSL)?Tools::getShopDomainSsl():Tools::getShopDomain()).__PS_BASE_URI__,

I was about to write this off after failed searches, but “/public_html/x/classes/controller/FrontController.php” and “/public_html/x/classes/controller/ModuleFrontController.php” do exist. In my version. The first is a short file. The second has nothing I could find similar.

Mystery: there is no “front controller” module. But there is a file called modulefrontcontroller. Is this a clue? 


https://www.prestashop.com/forums/topic/447523-shopping-cart-is-empty-error/ GiantRobo thread June 15
- changes subject to no couriers error

https://www.prestashop.com/forums/topic/633254-after-add-to-cart-cart-is-empty/ Sini thread November 17
- summarizes other bugs and suggests a solution on >classes>cookie.php line 76ish, change the name of the cookie. I made the change but still get the empty cart error. Someone suggests emptying the cross-reference tables?

https://www.prestashop.com/forums/topic/636942-your-shopping-cart-is-empty-error/ Milsi thread November 17
About PS 1.5. No replies

https://www.prestashop.com/forums/topic/442877-cart-says-your-cart-is-empty-no-matter-how-many-products-i-add/

About PS? Dprovost thread May 2015
Suggests a test of .css in case is isn’t showing the cart contents by mistake. Test: add

.unvisible { display: none; }

To the end of your theme’s global.css file. I tried. No result when trying the cart in a fresh browser with caches turned off.

https://www.prestashop.com/forums/topic/636942-your-shopping-cart-is-empty-error/

Milsee thread. November 2017. Chrome only. No replies

https://www.prestashop.com/forums/topic/297624-solved-prestashop-156-shopping-cart-is-empty/
Gsoutfits thread PS 1.5 December 2013
This was a css problem stored in the cache.
All my css changes are in a separate editing module. I have disabled it. No result in community theme.

2011 thread skipped as too old

https://www.prestashop.com/forums/topic/392573-solved-empty-cart-problem-1609/

Simon68 / lacepatterns.eu thread, January 2015, PS1.6.0.9 - asks for list of solutions

Turn off ajax cart. Done. Problem remains

Someone lists PSForge bug tracker posts that have helped him
This is very frustrating, but I sympathise with Prestashop developers after reading https://medium.com/@prestashoppoweruser/prestashop-a-sad-story-8b7e0a8795b8
A bug marked “not replicable duplicate” is “closed” over-and-over again, which, to me, is no solution. Aircraft builders do not write “duplicate but not replicable, so solved” if their planes crash so often and inexplicably. Or sometimes they do but that turned-out to be metal fatigue so it was solved eventually.

The lead PHP and MySQL developer suggests disabling non Prestashop themes and modules, and switching back to the default bootstrap theme.

I found a switch in backoffice > advanced parameters > performance to turn-off all non-prestashop modules but id didn’t work, so I went down the list and turned-off each one and saw Prestashop Cleaner offering to tidy my database, and it did:
DELETE FROM `ps_order_carrier` WHERE `id_order` NOT IN (SELECT `id_order` FROM `ps_orders`)

2 line(s)

DELETE FROM `ps_order_invoice` WHERE `id_order` NOT IN (SELECT `id_order` FROM `ps_orders`)

1 line(s)

DELETE FROM `ps_order_invoice_payment` WHERE `id_order` NOT IN (SELECT `id_order` FROM `ps_orders`)

1 line(s)

DELETE FROM `ps_product_carrier` WHERE `id_product` NOT IN (SELECT `id_product` FROM `ps_product`)

1 line(s)

DELETE FROM `ps_specific_price_priority` WHERE `id_product` NOT IN (SELECT `id_product` FROM `ps_product`)

1 line(s)

Bug remains.

There is also an option to delete every order and customer record. I have none, so why not?
Orders and customers truncated

Bug remains.

The same developer suggests, if that fails “You should consult your apache logs or the javascript console of your browser”, and try the default bootstrap theme.

My javascript console led me here
example.com/img/p/en-default-home_default.jpg is called rather than
example.com/img/p/1/0/1/101-home_default.jpg

http://forge.prestashop.com/browse/PSCSX-6117 - the thumbnail image of a product is lost instead of going to the cart, even if I re-build thumbnails in the back office. 

There is a patch for the cart.php written on Github, mentioned as a solution to the image problem as though future releases would include that patch, but I am on a future release and I cannot find cart.php, so the patch doesn’t help.

I’ve got this far and am nowhere:
https://www.prestashop.com/forums/topic/392573-solved-empty-cart-problem-1609/#comment-2101779

Now I have found an error message about regional settings deleting carts, which is good.
Now I have also tried deleting and re-instating the /subdirectory/ setting just to clear defaults, but have lost the site entirely. 
https://www.prestashop.com/forums/topic/149001-can-i-change-prestashop-base-url/?do=findComment&comment=2905656
...might be an answer

  • Thanks 1
Link to comment
Share on other sites

  • 4 months later...
On 8/5/2018 at 11:24 PM, vlado92 said:

2. Other cookie problem, that manifest itself with empty cart along with login problem (user cannot be loged in, always is redirected back) is problem with cookie size (max size is about 4096 bytes). After some research, we have decrypted clients problematic cookie, and found out that module responsible for this mess is actually "blockviewed". If someone is interested, we could create module that creates overrides for those functions. Hope this helps to understand the problematic behaviour 

Thank you very much for this solution. Disabling: "Viewed products block" saved my day.

Link to comment
Share on other sites

  • 3 months later...
  • 11 months later...

We've had the same issue - after adding a product to cart in Presta 1.7.6.4, the cart was empty. It happened only while being a guest. I started debugging in controllers/front/CartController.php and found out, that for some reason every time I added this product to cart, new cart has been created and id_cart stored to cookie. But immediatelly forgotten and after adding the product another time, new cart was created again and id_cart stored to cookie again and so on.

Then I've found it happens only with specific product and after adding a different product into cart, I can also add the problematic product without any issue. So I examined the difference between cookie after adding the problematic product and non-problematic product. I've discovered, that after adding non-problematic product, the cookie contains also id_guest and id_connection while when adding a problematic product, it doesn't containt these two.

Finally, I've found the reason - and it's been funny trivial - the problematic product had too long description (summary) - 995 characters as counted by backoffice, but in fact 1221 characters when viewed as HTML source including HTML tags. After shortening to less than 1000 characters including HTML tags, everything started working fine. So due to that long summary, something broke during the proccess of adding to cart and id_guest and id_connection was not saved into cookie and and the created id_cart was not paired to the guest session.

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

On 4/4/2020 at 11:43 PM, FunkyMark said:

We've had the same issue - after adding a product to cart in Presta 1.7.6.4, the cart was empty. It happened only while being a guest. I started debugging in controllers/front/CartController.php and found out, that for some reason every time I added this product to cart, new cart has been created and id_cart stored to cookie. But immediatelly forgotten and after adding the product another time, new cart was created again and id_cart stored to cookie again and so on.

Then I've found it happens only with specific product and after adding a different product into cart, I can also add the problematic product without any issue. So I examined the difference between cookie after adding the problematic product and non-problematic product. I've discovered, that after adding non-problematic product, the cookie contains also id_guest and id_connection while when adding a problematic product, it doesn't containt these two.

Finally, I've found the reason - and it's been funny trivial - the problematic product had too long description (summary) - 995 characters as counted by backoffice, but in fact 1221 characters when viewed as HTML source including HTML tags. After shortening to less than 1000 characters including HTML tags, everything started working fine. So due to that long summary, something broke during the proccess of adding to cart and id_guest and id_connection was not saved into cookie and and the created id_cart was not paired to the guest session.

Does your described method still working?  How exactly you have shortened this characters?

Link to comment
Share on other sites

  • 5 months later...

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...