0

I need to reload order summary section on selecting the payment method in magento 2

1
  • Welcome to MSE. Please add more details what you coded and tried. Your question comes under "Low Quality Posts" and will be deleted in the absence of clarity so i request you to add complete and more details. Thank you
    – Jarnail S
    Jan 30, 2019 at 15:15

1 Answer 1

3

Create a file called requirejs-config.js within your module-theme folder (don't do this in vendor files).

In there add:

var config = {
   map: {
    '*': {
        custom:'Magento_Theme/js/custom',
    }
  }
};

Then create a file called custom.js under module-theme/web/js (Again not in your vendor files). And in there add:

define([
'jquery',
'Magento_Checkout/js/action/get-totals',
'Magento_Customer/js/customer-data'
 ], function ($, getTotalsAction, customerData) {
    $(document).ready(function(){

        var deferred = $.Deferred();
        getTotalsAction([], deferred);
    });
});

This should refresh the cart page when the page loads. If you want this to happen at a certain point just listen for a change event such as:

$(document).on('change', 'input[name$="[qty]"]', function(){
    var deferred = $.Deferred();
    getTotalsAction([], deferred);
});

Hope this helps

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.