2

Is there any way to update the minicart view? Now I'm using

      require([
            'Magento_Customer/js/customer-data'
        ], function (customerData) {

            alert("hola");
            var sections = ['cart'];
            customerData.invalidate(sections);
        });

But it only refreshes the view by updating the page.

I'm looking for ways to make the changes reflect without having to reload the page. Any ideas?

9

You can try below code.

require([
           'Magento_Customer/js/customer-data'
        ], function (customerData) {
            var sections = ['cart'];
            customerData.invalidate(sections);
            customerData.reload(sections, true);
        });
  • when i recharge the page show "You added Pantalon vaquero to your shopping cart." could remove the message for no show? – Miguel Jun 9 '17 at 9:52
  • NOt working for me.I am removing an item from minicart it is not removing checkout button. – akgola Oct 19 '18 at 4:45
1

The right way of doing this (usually it's enough) is adding your action to section.xml. See example in Magento_Checkout:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
<action name="checkout/cart/add">
    <section name="cart"/>
</action>

Actually after that magento will do the same as @suresh-chikani showed on ajaxComplete event

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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