0

I have referred the link

Magento2 : Show summery total on checkout page

and made changes in abstract-total.js and shipping.js. Now order summary is displayed and shipping amount updates correctly on changing shipping method but it is not getting updated in grand total. Any solution ?

1

Override grand-total.js file too and define step-navigator,

define([
    'Magento_Checkout/js/view/summary/abstract-total',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/model/step-navigator'
], function (Component, quote, stepNavigator) { 

after that replace getValue() function with below code :

getValue: function () {
            var totals = quote.getTotals()();
            if(typeof(quote.shippingMethod()) != "undefined" && quote.shippingMethod() !== null) {
            var shippingMethod = quote.shippingMethod();
            var price =  shippingMethod.amount;
        }
            var plus = "";
            var minus = "";
        if(totals['base_shipping_amount'] < price){
            plus = totals['base_shipping_amount'] + price;
            return this.getFormattedPrice((this.getPureValue() + price));
        } else if(totals['base_shipping_amount'] > price){
            minus = totals['base_shipping_amount'] - price;
            return this.getFormattedPrice((this.getPureValue() - minus));
        }
        return this.getFormattedPrice(this.getPureValue());
        } 

Clear Magento cache and check.

  • I didnt understand your answer. Will u pls explain? – Magento User Dec 26 '18 at 9:00
  • You just need to update getValue() function in the grand-total.js file. – vishal Dec 26 '18 at 9:11
  • This does not work to fixed the problem – Cypher909 Mar 2 at 15:55
1

In shipping.js you must also add the dependency for Magento_Checkout/js/model/cart/estimate-service. This will trigger the recalculation of the grand total when the shipping cost is updated.

define([
    'jquery',
    'Magento_Checkout/js/view/summary/abstract-total',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/model/cart/estimate-service'
], function ($, Component, quote, estimateService) {
    'use strict';
    //...

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.