Magento: add to cart shows empty cart - magento

When I add a product to my cart, I get the "empty cart" page.
I run Magento 1.7.0.2.
I have a writable session dir (var/session/) and see sess_* files being created
I have the following cookie settings (System -> Configuration -> Web -> Session Cookie Management): Cookie Lifetime = 10800 (3 hours), Cookie Path = empty, Cookie Domain = empty, Use HTTP Only = Yes, Cookie Restriction Mode = No
I already tried: Use HTTP Only = No
The cart/checkout is set to go trough HTTPS, but I have the same base URL's for secure and unsecure. I tested this (HTTPS front end Yes and No) and it makes no difference...
I checked the addAction() on the Mage_Checkout_CartController and it gets the params and adds the product + saves the cart
I checked the chooseTemplate() method on Mage_Checkout_Block_Cart and this gets a cart's items count of NULL, when I manually/ (hard code) change this to 1, then the cart 'filled' template gets rendered (also rendered correctly, but 'of course' no items)
I cleared cache and session data in between testing and trying...
Anyone had this and fixed this somehow? Or any suggestions on what to try next?

The following solutions worked for us. This is a late answer and I still consider to post an answer to this question so that it may help other people who are still stuck and looking for more solutions to try.
First we switched our domain to www which caused this problem. We fixed that problem by removing the caches, sessions and cookies. But we started experiencing that problem again and we thought that it was complex situation for us since we changed some javascript, www and SSL. But finally we found out that some products had 0 quantity and we were unable to add to cart. The cart page was hiding the out of stock message as error since it was ajax cart page through another module and theme. Then We set correct quantities for those items and the empty cart page is gone.

Related

magento Shopping cart is empty when going to checkout

Seem to be having a session issue based on my research but none of the solutions that people say to try seem to change anything.
This problem is only happening in IE and Safari. I add an item to cart, then I Proceed to Checkout which then shows
Shopping Cart is Empty
You have no items in your shopping cart.
Click here to continue shopping.
So far I have set cookie lifetime to 86400. Use SID on frontend to Yes otherwise adding an item to cart will instantly say You have no items in your shopping cart. Validate HTTP_USER_AGENT to yes. I have also tried setting Cookie Lifetime to 0.
Deleting Var/Cache folder solved the problem. I first renamed it, which then created a new cache folder. After that I was able to proceed to checkout. I had a lot of folders inside the cache folder I believe it was mage-0 - mage-i so 0-9 then a-i.
I hope this helps someone else in the future it seems that the backend cache removal isn't removing this cache.

Codeigniter Cart wrong cookie

I embedded this example http://net.tutsplus.com/tutorials/php/how-to-build-a-shopping-cart-using-codeigniter-and-jquery/ to my shop.
I faced an issue that $total = $this->cart->total_items(); gets quantity value.
And if compare cookies from my site with cookie from example this is the difference:
my ...total_items"*;i:66;*s:10:"cart_total";i:5610;}}.....
original ...total_items*";s:1*:"1";s:10:"cart_total";s:4:"1499";...
So as you can see cookie stores wrong. I tried logging variables in Cart library but for this moment haven't caught problem. And I have another issue, as I think related with cookie I cannot add more than 7 items in cart. But I investigated this issue a bit, and mentioned only for helping.

Magento 1.5.0.1 Items vanish from cart when user logs in at checkout

Here's a quick step by step of what's been happening.
The user adds a product to their basket/cart and proceeds to the checkout. They may choose to Register, Checkout as Guest or Login with an existing account.
Customer Logs in with existing account.
They get taken to a page informing them that their shopping cart is now empty. Yet in the top right the link for My Cart still reads (1 item) next to it. Clicking this link just loads the same 'Shopping Cart is Empty' page.
Some other tests I did showed the following:
User logs in, adds 3 items to his cart, but logs out before going to checkout.
He comes back to the site at a later date and starts a fresh order for just 1 product, choosing to login at checkout.
Upon doing so his cart cart displays the 3 items from his previous session (his new product missing), yet the My Cart link reads (4 items) next to it.
Does anyone know what might be causing the items to vanish from the cart during this transition from not being logged in to being logged in?
I have seen this problem before on servers that are uhosin.session.encryptrunning the suhosin patch. I'm assuming that you are running a secure cart (if not you should) what is most likely happening here is that your session is being lost each time you change between http and https.
When you switch between the HTTP and HTTPS, your HTTP session is not being passed to the HTTPS session. This can be resolved by placing the following in your .htaccess or php.ini file:
php_value suhosin.session.encrypt Off
Let me know if it works or if you are still having the same problem, remember to restart your server once you have made the changes.
I solved it.
Turns out the ZetaPrints OrderApproval module was installed and was overriding part of the checkout page.
Apparantly it was something that had been added, decided it was no longer needed and then forgotten about.
I disabled it and flushed the cache and got my old checkout page back.
All working again.
For me, it was a matter of Cooke Session Control and setting my 'Cookie domain' value as such:
.mydomain.com
Yes, with a period in front.

Magento session lost when switching to https from http

I've searched high and low for a solution to this, with no luck. My host told me they are too busy to help.
Magento 1.4.2 // SSL cert
1- When I add an item to cart, the page reloads and my item is added to cart. [good]
2- Next, I click home, and my items are no longer visible in cart sidebar. [bad]
3- Next, I click "Tops", and my items are still not visible in cart sidebar. [bad]
4- Next , I click "Bottoms" and the items show just fine.
In all cases where the cart isn't visible, I can add https to the URL and the cart loads up just fine. Can anyone help me figure out why my session is being lost between http and https?
I have all my backend web cookie settings set to "no" except for sID.
Also- When a user is logged in, the cart items ALWAYS show on the right. It's only screwy if they're a guest.
Thanks guys, if you need me to post any code let me know.
wwwdotlylifdotcom
EDIT: Here is a screenshot of my cookies session in firebug (not exactly sure what I am looking at). Hope this helps.
And here is my Session settings in magento: I have tried just about every variation of turning these on and off.
EDIT!
This issue has actually been narrowed down to a cache issue. We found out that when the cache is dumped/deleted, the website works properly. But after a few minutes of surfing the problem happens again. Does anyone have any idea? (And should i change the question title?)
I'm using a module called Lightspeed from TinyBrick, and it seems the new cache options are messing with our site. =( I'm contacting them shortly.
**EDIT Tinybricks excellent support helped us out. Thanks for all of your suggestions.
Is the session cookie being set to be HTTPS-only? That'll prevent it from being carried over to regular HTTP requests, effectively giving the user two different sessions.
You have in your screenshot two frontend cookie with two domains, one with www and an other one without. Check if you have a correct domain name in the configuration > Web tab > Cookie Management > Cookie Domain (or something close to that). If it's empty set it to ".mydomain.com" and try again.
Check if you don't have different cookie domain in your configuration in the other store views, set them to "use website".
If still doesn't work, What are the values of the fields of cookie management and the cookie validation settings
We were experiencing similar issues where our custom nav (depending on whether a user was logged in or not, was not very consistent across different pages.
We followed the suggestion # http://ka.lpe.sh/2011/06/19/magento-checking-customer-admin-is-logged-in-or-not/ to check if a user was logged base on the frontend session variable before a rendering a particular block, and it seems to have done the trick.
Perhaps you can try something similar.
Tinybricks excellent support helped us out. Thanks for all of your suggestions. This was a localized problem based off cache and a module called Lightspeed.

Magento - Internet Explorer Cart Issues

I'm on Magento 1.4.1 and get regular calls (2-3 per week) from customers that they are unable to add products to their cart. The symptoms are the same for customers: All use IE (7 or 8, most commonly). When they attempt to add to cart, they are taken to an empty cart page. Repeated attempts do not resolve the issue. I have not been able to verify, and the only version of IE I have access to is 9. I would dismiss this as user error except for:
Generally lower-than expected conversion rate on my site (explainable if large % of IE customers are unable to transact).
Consistency of symptoms: Browser and version, action that is failing
I assume this is an issue with setting the session or cookie (but could totally be wrong and am open to other suggested causes). If it is a cookie issue, I've found this post and this post from Stack Overflow which give a little information, but not a solid idea of how to go about confirming it is a cookie or session issue.
Can someone suggest the best way to get started with diagnosis?
setting cookie lifetime to 86400 as recomended here did the trick for me.
IE9 bundles development tools (from settings menu) and this allow you to emulate ie7 - ie9 versions in all compatibility modes.
If you are getting blank pages then there is always a php error behind this and you can see those errors from your server php error log.
We had a similar issue with items disappearing from the cart, it only happened in a store that was using a subdirectory of the main domain, and only with ie9 and older ie's. We also had varnish running on the frontend, and magento 1.4.1.1
e.g.
www.example.com = main store
www.example.com/sub/ = secondary store
After adding items to the secondary store basket in ie9, you could then go to the main store and add more items, return to the basket page and all was well then if you went to another secondary store product and added another item to the basket, then visited the basket page all previous items had gone, but the one just added was there.
We found we could consistently reproduce this by visiting a secondary store product page, adding to the basket, visit the basket - item is there, return to the product page, return to the basket, item has gone. It turned out to be a bad background image url in the stylesheet, and the rule was only used by the product page template, this 404 error was enough to cause ie9 and older ie's to lose the session and start a new one.
ie10 and 11, chrome, firefox and safari didn't have this problem at all, so if you're getting intermittent customer reports of baskets suddenly being empty, check the whole site for 404's, all it can take is one missing image to lose the session for ie9 and older ie's.

Resources