cancel
Showing results for 
Search instead for 
Did you mean: 

Shopping Cart Won't List Items Added

SOLVED

Shopping Cart Won't List Items Added

We're running Magento 1.9.1 with a custom Theme purchased through Magento Connect (https://www.magentocommerce.com/magento-connect/electro-appliances-responsive-theme-for-electronics-... Everything was working great, up until a few days ago (or more like a week ago). Now, whenever items are added to the shopping cart, the shopping cart properly displays "Cart: 'x' item(s) - $X.XX", where 'x' is the number of items currently added to the shopping cart and '$X.XX' is the correct sub-total of all the items, but when we click on the cart drop-down, it always displays "You have no items in your shopping cart." What's worse is that the <form> tag "search_mini_form" disappears from the page when items are added to the cart. We've noticed that it appears under the cart drop-down when its clicked. So, we'll see a singly <lo> stating "You have no items...", then the form search as part of the list... Currently, the only way to remove items previously added to the cart is to add another item and then clear one or more items (or the entire cart) from the subsequent page. Or go through the check-out process, and clear it there. Obviously this is not good and it will give our customers a very poor opinion of our site. One good thing to note is that when the cart is emptied (again), the issue of the search form ("search_mini_form") appears to resolve itself; it again appears on the page, where it belongs. Its all very odd! I'm thinking its a combination of PHP code coupled with layout issues. I found the phtml file that constructs the cart and it appears the method called to get the shopping items is not returning. Unfortunately, there are no errors on the page (i.e., nothing in the console when I inspect the page), or errors in the logs for me to debug further. We recently had someone from of-shore working on the site to add SEO content, but they only added meta data info and link, and we restricted his access to pages and static blocks, etc. Is it possible they messed something up? I've been trying to investigate, but everything I try is fruitless... Any suggestions or help would be greatly appreciated; thanks! -Voltaire

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Shopping Cart Won't List Items Added

In case anyone else is experiencing this same issue, this is what worked for me:

 

Modify the "app/design/frontend/default/<yourtheme>/template/checkout/cart/sidebar_header.phtml" file. This .phtml file contains the logic for constructing the shopping cart drop down. If you rename it and refresh your Magento site, the cart will no longer be displayed. First make a backup of the .phtml (i.e., sidebar_header.phtml.bak) then modify the original, changing the call to getRecentItems() to $this->getQuote()->getAllItems() instead. Alternatively you can keep getRecentItems() and simply pass in a prameter (e.g., getRecentItems(10) to display the 10 recent items added to the cart) or modify the "Maximum Display Recently Added Item(s)" configuration under "System->Configuration->Checkout->Shopping Cart Sidebar". The configuration to "Display Shopping Cart Sidebar" may also be causing this issue.

 

The posting that lead to my solution was taken from StackOverflow: http://stackoverflow.com/questions/14062310/get-all-products-in-cart-instead-of-most-recent, and while unrelated, it gave me direction.

View solution in original post

3 REPLIES 3

Re: Shopping Cart Won't List Items Added

This is due to the cookie problem, not in browser but in Magento itself. In Magento, by default cookie’s lifetime is set to 3600 (1 hour). But if the end users computer time runs ahead of server’s time, cookies will not get set for magento frontend as well as backend. For example, end user’s computer time is 1 hour forward than server’s time, that means the cookie (holding user’s session id) will expire as soon as user logs in or tries to add an item.

To solve this, set cookie’s lifetime to 86400 (1 day) instead of 1 hour and everything will work as expected. You can also set cookie lifetime to 0, so that cookie will only expire when the user’s browser is closed.

Go to: Magento backend -> Sytem -> Configuration -> Web -> Session and Cookie Management Set cookie lifetime to 86400 and save. Everything will work as expected now.

 

Regards

Manish

OpenSource Expert | OpenSource Technologies | www.opensourcetechnologies.com
Magento plugins released: http://www.opensourcetechnologies.com/product/product-category/magento-extensions

Re: Shopping Cart Won't List Items Added

Hi Manish,

 

Thank you for your response. While searching the web, I came across a similar suggestion and already tried setting the "Cookie Lifetime" (in the Session Cookie Management section of Web) to 86400, but this did not solve the problem. After more digging, I finally found the solution and it entailed modifying the "sidebar_header.phtml" file. I modified the call to getRecentItems() to $this->getQuote()->getAllItems() and that finally resolved the issue... I was led to this solution, after coming across the following post on StackOverflow: http://stackoverflow.com/questions/14062310/get-all-products-in-cart-instead-of-most-recent

 

After making this change, I also checked the configuration under "System->Configuration->Checkout->Shopping Cart Sidebar" and noted that "Display Shopping Cart Sidebar" was for some reason set to "No". I don't know if this is the default or if someone else accidentally set it to "No". Would setting this configuration to "No" have such a drastic affect on the site, as my problem statements indicates? It shouldn't, but I never changed it to "Yes", since the code modification on the phtml file did the trick.

 

I'm still very confused as to why this all of a sudden started happening, and if its due to this configuration, why such a config. exists in the first place if its buggy and who changed it. In any case, the issue is now resolved and its not worth me pondering further.

 

Thanks again for your suggestion and your response!

 

Regards,

Voltaire

Re: Shopping Cart Won't List Items Added

In case anyone else is experiencing this same issue, this is what worked for me:

 

Modify the "app/design/frontend/default/<yourtheme>/template/checkout/cart/sidebar_header.phtml" file. This .phtml file contains the logic for constructing the shopping cart drop down. If you rename it and refresh your Magento site, the cart will no longer be displayed. First make a backup of the .phtml (i.e., sidebar_header.phtml.bak) then modify the original, changing the call to getRecentItems() to $this->getQuote()->getAllItems() instead. Alternatively you can keep getRecentItems() and simply pass in a prameter (e.g., getRecentItems(10) to display the 10 recent items added to the cart) or modify the "Maximum Display Recently Added Item(s)" configuration under "System->Configuration->Checkout->Shopping Cart Sidebar". The configuration to "Display Shopping Cart Sidebar" may also be causing this issue.

 

The posting that lead to my solution was taken from StackOverflow: http://stackoverflow.com/questions/14062310/get-all-products-in-cart-instead-of-most-recent, and while unrelated, it gave me direction.