12

A lot of our customers are complaining that they add stuff to the cart & then when they proceed to checkout they are redirected to an empty cart.
We thought that it might be a result of too short session time, so we tried increasing the cookie/session lifetime to 86400 (on both admin & server).
After that, I tried to reproduce the problem & managed to achieve the weird behavior as you can see on the attached screenshot.
I added products to cart, came back after about 20-30 minutes & saw my items in the minicart. then I proceeded to checkout & it redirected me to this empty cart while the minicart is still showing my items (refreshing the page also didn't work): enter image description here

-- Any Idea?


UPDATE: So far we managed to solve this issue by changing back the session configuration to use files (disabled Memcached). I know that Magento recommends using Memcached & have no idea what caused this issue...

2 Answers 2

2

app\code\Vendor\Extension\etc\frontend\section.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="extension/controller/action">
        <section name="cart"/>
    </action>
</config>

In this action parameter name, you have to pass the full action (For ex. checkout/cart/add ) in which cart is updated. It means you programmatically delete or add a product to cart to the shopping cart.

Lastly, Comment down below if you face any issue while using this code.

Happy Coding!

0

Magento places all customer specific data(shopping cart, customer name, etc...) in local storage in order to prevent caching on proxies like Varnish. Later this data is inserted into the page using JS. The behavior you observed is a misconfiguration of cache lifetime. Ideally, it should be aligned with session lifetime.

1
  • As I said, we increased both session & cookie to 86400, that didn't help. The only thing that seems to fix the issue was to disable the memcached (which was configured as suggested by Magento's docs). We stopped checking the issue after that so I have no idea what actually caused it.
    – Pini
    Commented Mar 2, 2018 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.