5

I try following js code to reload cart summary section.

 <script>
     require(['jquery',
             'jquery/ui',
             'Magento_Checkout/js/model/quote',
             'Magento_Checkout/js/model/cart/totals-processor/default'
     ], function($,
                 quote,
                 totalsDefaultProvider){
         "use strict";
           jQuery(document).ready( function() {
               jQuery(".item_shipping").change(function(){
                   alert("Page loaded.");
                   totalsDefaultProvider.estimateTotals(quote.shippingAddress());
               })
           });
       }); 

Following error give on console TypeError: options is undefined return $.getJSON(options.sectionLoadUrl, parameters).fail(function (jqXHR) {

2 Answers 2

3

you need to add following code in your js file

define([
    'jquery',
    'Magento_Checkout/js/action/get-totals',
    'Magento_Customer/js/customer-data'
], function($, getTotalsAction, customerData){
    'use strict';
    jQuery(document).ready( function() {
        jQuery(".item_shipping").change(function(){
            var deferred = $.Deferred();
            getTotalsAction([], deferred);
        })
    });
});
4
  • How can i get Total Value from this getTotalsAction([], deferred); Commented Aug 11, 2020 at 6:28
  • i have add this code in my custom js but got an error of getTotalsAction how can i solve that @Chirag Gondaliya? Commented Oct 23, 2020 at 13:28
  • 1
    not worked for me
    – Dinesh
    Commented Nov 4, 2020 at 12:23
  • how to reload the summary in admin Commented Feb 16, 2021 at 11:11
0

One can try the below code (Tested on the cart page only):

define([
    'jquery',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/model/cart/totals-processor/default',
    'Magento_Checkout/js/model/cart/cache'
], function($, quote, totalsProcessor, cartCache){
    'use strict';
    $(document).ready( function() {
        $(".item_shipping").change(function(){
            cartCache.clear('cartVersion');
            totalsProcessor.estimateTotals(quote.shippingAddress());
        })
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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