I have customized mini-cart. and place one new button Clear shopping cart. it's work fine. all item are deleted successfully. but mini cart total not updated in Magento 2. total updated only by one item.

check snap. https://i.stack.imgur.com/pUvWY.png


To update the mini-cart in you need to create a sections.xml in your module etc/frontend directory.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <action name="checkout/cart/add">
        <section name="cart"/>

Just replace checkout/cart/add with your modulename/controller/actionname and clear your webshop cache. You can also find the same thing in magento-checkout module from below path,


Magento does this job from below path (Just for debugging purpose),


$(document).on('ajaxComplete', function (event, xhr, settings) {
    var sections,

    if (settings.type.match(/post|put|delete/i)) {
        sections = sectionConfig.getAffectedSections(settings.url);

        if (sections) {
            redirects = ['redirect', 'backUrl'];

            if (_.isObject(xhr.responseJSON) && !_.isEmpty(_.pick(xhr.responseJSON, redirects))) { //eslint-disable-line
            customerData.reload(sections, true);

Alternatively, you can also do by adding just piece of javascript code on your AJAX (I am assuming you are doing this operation by AJAX)

        ], function (customerData) {
            var sections = ['cart'];
            customerData.reload(sections, true);
  • nice answer bro...
    – Amit Bera
    Nov 22 '17 at 12:49
  • i have try this but it update only for 1 item
    – Ajay Patel
    Nov 22 '17 at 13:45
  • @keyur Shah can you please help me in this question, magento.stackexchange.com/questions/279346/…
    – Mujahidh
    Jun 24 '19 at 10:06
  • what is this section.xml used for,
    – Mujahidh
    Jun 24 '19 at 10:12
  • @AjayPatel did you get the solution. i am facing same issue
    – Arjun
    Jun 29 '20 at 6:27

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.