1

I am using Magento2.1.9 when I am going to the checkout page, order summary reloaded default magento's way so I used a js to our custom module added below code into it

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

After that applied all commands but not working in reload order summary if any one idea reply me I have try to in other stack solution regarding this but not getting success.

1

I used one of the very good tutorial for this purpose

you need to add following code in your js file

/*browser:true*/
/*global define*/
define(
    [
        'ko',
        'jquery',
        'Magento_Checkout/js/model/cart/totals-processor/default',
        'Magento_Checkout/js/model/cart/cache'
    ],
    function (ko, $, defaultTotal, cartCache) {
        'use strict';
        return Component.extend({
            updateamount:function () {//your function to update amount
                //your code to update amount
                //after successfull execution you need to add these lines.
                cartCache.set('totals',null);
                defaultTotal.estimateTotals();
            }
        });
    }
);

cartCache.set(‘totals’, null) : set the cart total to calculate totals again, if not using this line then estimateTotals() returns the totals for cache.

defaultTotal.estimateTotals(): executing the process to calculate totals.

Reference: https://webkul.com/blog/update-cart-totals-by-js-on-checkout-page-magento2/

I hope this will help

  • where is this js put it in our custom module js or other custom js create – Rv Singh Mar 13 at 10:25
  • in checkout i used custom fee module and this module call two js one for cart and other is summary js – Rv Singh Mar 13 at 10:25
  • I have to use this code but my layout mess up so if u suggest another way.in console getting js error – Rv Singh Mar 13 at 14:20
  • In console getting error my checkout page layout mismatch – Rv Singh Mar 14 at 6:04

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.