Magento – How to show subtotals in first checkout step

checkoutmagento2onepage-checkouttotals

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.

Best Answer

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