How to Update Mini Cart in Magento2 ?

  • author-img Nidhi Arora
  • 7 years
How to Update Mini Cart Magento2

Update mini cart when you are submitting a form

Magento provides a way to update minicart if you are submitting a form. First of all create sections.xml file in ‘etc/frontend’ folder in your module.

Now write following code snippet in sections.xml file

<?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="modulename/controller/addProduct">
<section name="cart"/>
</action>
</config>

Action name: action name is controller where you are submitting form.

Example of this situation may be when you want to set custom price of product in your own controller. This approach will work when you are using POST or PUT form submitting. It will also work for AJAX request.

If you still have any query regarding this “How to” or would like to add some suggestions to this solution, let us know your feedback or query at sales@envisionecommerce.com, and don’t forget to share this “How to” blog with your fellow Magento 2 users!

Download Blog

ENQUIRY

Ready to Get Started

Communication is the key for us to understand each other. Allow us to understand
your requirements or queries. Present us with an opportunity to serve you.

Fill out the form and out team will get back to you
within 24 hours

    Head Office

    815 Brazos St STE 500, Austin,
    TX 78701, USA