Magento – Magento 2 – How to reload cart summary section

cartcheckoutmagento2

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) {

Best Answer

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);
        })
    });
});