6

I want to add the subtotals to first checkout step "shipping" into the sidebar. In the checkout_index_index.xml

I can see the totals but I have no clue why it is not loading in the first checkout step.

5 Answers 5

10

All of these solutions imply that you need to copy the abstract-total.js to your own theme, but this is not necessary. Even more so: it might introduce new problems as soon as a Magento update decides to update the original abstract-total.js.

A better (more unobtrusive) solution to this is to make use of a RequireJs mixin. This way you can extend a JavaScript object provided by Magento and only add your own adjustments:

In view/frontend/requirejs-config.js:

var config = { config: { mixins: { 'Magento_Checkout/js/view/summary/abstract-total': { 'Vendor_Module/js/abstract-total-mixin': true } } } }; 

In view/frontend/web/js/abstract-total-mixin.js:

define([], function () { "use strict"; return function (target) { return target.extend({ /** * @return {*} */ isFullMode: function () { if (!this.getTotals()) { return false; } return true; } }); } }); 

Now you have the same results in an upgrade-safe way ;-)

1
  • 1
    Thank you! I can confirm this works on 2.3.1 and the shipping totals are also updated when the method is changed Commented Jun 26, 2019 at 10:16
4

I had a similar issue and this is the way i managed to get it working.

You can override the following file

app/code/Magento/Checkout/view/frontend/web/js/view/summary/abstract-total.js

and update isFullMode function to return

true

instead of

return stepNavigator.isProcessed('shipping');

isFullMode: function() { if (!this.getTotals()) { return false; } return true; } 

Full code of overriden abstract-total.js file

/** * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ /*global define*/ define( [ 'uiComponent', 'Magento_Checkout/js/model/quote', 'Magento_Catalog/js/price-utils', 'Magento_Checkout/js/model/totals', 'Magento_Checkout/js/model/step-navigator' ], function (Component, quote, priceUtils, totals, stepNavigator) { "use strict"; return Component.extend({ getFormattedPrice: function (price) { return priceUtils.formatPrice(price, quote.getPriceFormat()); }, getTotals: function() { return totals.totals(); }, isFullMode: function() { if (!this.getTotals()) { return false; } return true; } }); } ); 

Hope it helps

1
  • Worked for me, but it dose not update shipping price if I change shipping methods, like if I am on cartpage, selected "freeshipping-0.00$" & proceed to checkout, now on checkout page#shipping tab it shows default selected "freeshipping-0.00$", thats good(in working condition), but when on same page#tab I select another method like selected "Homedelevery-10.00$" in sidebar nav it shows "Homedelevery-0.00$", So it updates shipping method name/title but not price & also not calculating totals(ajax not called), Any solution for that @St0ik Commented Nov 18, 2016 at 7:25
2

In addition to enabling the full mode for the cart summary, you want to make sure its shipping price, taxes and grand total get refreshed when picking/changing shipping methods during that first step.

You can copy the following file to your theme (don't edit it directly):

module-checkout/view/frontend/web/js/view/summary/shipping.js

Add the Magento_Checkout/js/model/cart/estimate-service to the list of dependencies like so:

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'; //...

Source: https://magento.stackexchange.com/a/176238/62137

1

Maybe it is interesting to take a look at the Clean Checkout module which simplifies the checkout and also adds the subtotal to the shipping step.

https://github.com/danslo/CleanCheckout

1

Basically its not magento default functionality to enable total summary in shipping step. So we have to change some of files.
Let's follow below steps:

Step:1 To enable summary override below file.

app/code/Magento/Checkout/view/frontend/web/js/view/summary/abstract-total.js

override isFullMode()

 isFullMode: function() { if (!this.getTotals()) { return false; } // return stepNavigator.isProcessed('shipping'); return true; } 

Step:2 To change shipping price value on selection of the shipping method You can override the following file.

app/code/Magento/Checkout/view/frontend/web/js/view/summary/shipping.js

change getValue() function.

getValue: function() { if (!this.isCalculated()) { return this.notCalculatedMessage; } //var price = this.totals().shipping_amount; /* comment this line and add below two lines. */ var shippingMethod = quote.shippingMethod(); var price = shippingMethod.amount; return this.getFormattedPrice(price); } 

It is working (y).

1
  • Great Work, But Order Totals Not Updating on Shipping method Selection. Commented Oct 11, 2018 at 13:54

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.