1

How can I empty my cart value when order successfully done in Magento 2. This issue only done with logged-in user how can I handle this issue. Is there any solution for this?

3
  • This issue you faced in minicart right? Sep 18, 2020 at 12:50
  • 1
    Yes I'm facing this issue on minicart but when I reload success page its redirect to cart page also which is not empty Sep 18, 2020 at 12:52
  • you have installed any extension that customizes the cart? Or check the order that you have placed. Sep 18, 2020 at 13:44

1 Answer 1

1

For update minicart section first we create a sections.xml in /etc/frontend/

<?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="test/process/observer">
        <section name="cart"/>
    </action>
</config>

And after apply Ajax on particular section phtml

And one more solution founded

require([
           'Magento_Customer/js/customer-data'
        ], function (customerData) {
            var sections = ['cart'];
            customerData.invalidate(sections);
            customerData.reload(sections, true);
        });
1

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.