Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    magento-hyperlocal-marketplace-guide

    How to Update Item Quantity in Minicart Magento2

    Here we learn, How to Update Item Quantity in Minicart Magento2

    1. Add custom controller to the customer data section, so when quantity will change then, it will update minicart automatically.
    This is because when any ajax request get complete, then the Magento looks for the section to be update.

    you can see in this file: Magento/Customer/view/frontend/web/js/customer-data.js


    When any request gets complete on DOM it’s looks for the section, if section is there it reload
    the section.

    Let’s create Webkul/Knockout/etc/frontend/sections.xml file


    here you can see we have defined our Controller path.

    2. Now Create js file where you need to updated the Minicart.


    3. Finally the last thing is to create Controller File:
    Webkul/Knockout/Controller/Ajax/CartUpdate.php


    That’s it.

    . . .

    Comments (4)

    Add Your Comment

  • Pooja Mistry
    Where is ‘knockout-test’ template file ??
  • Andreas von Studnitz
    You should fix an error: the file is called “sections.xml” instead of “section.xml”. With that change, it works perfectly, it has helped me a lot!
    • Webkul Support
      Thanks for the information
  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close