Magento 2 – Update Cart Summary HTML

ajaxcartmagento2shopping-carttotals

When I use a bullet to increase qty then I use ajax to update cart. After call ajax how to update cart summary. I am stuck here please help me out from this.

also, I used

$("#cart-totals").trigger('contentUpdated');

line in response but its not working 🙁 🙁

Best Answer

Update cart summary in ajax response has been solved, we need to call getTotalsAction() javascript function as i mentioned below code :

demo.js

 define([
        'jquery',
        'Magento_Checkout/js/action/get-totals'
        ], function ($, getTotalsAction) {
        "use strict";

          $.ajax({
                method: "post",
                url: demoUrl, //your ajax Url
                data: {/*here post data*/},
                dataType: "html",
                success: function (resp) {
                   //below two lines refershing cart summary
                    var deferred = $.Deferred();
                    getTotalsAction([], deferred); //this function already created in Magento_Checkout/js/action/get-totals.js file
                }

            });

});
Related Topic