1

I have moved the summary one step up in the Magento 2 checkout. I would like to update the summary once i select a shipping method.

Does anyone has suggestions how to pull this off?

5

You just need to add the following file to your theme on path:

[theme]/Magento_Checkout/web/js/action/select-shipping-method.js

define(
[
    '../model/quote'
],
function (quote) {
    "use strict";
    return function (shippingMethod) {
        quote.shippingMethod(shippingMethod)
    }
}
);

will become:

define(
[
    '../model/quote',
    'Magento_Checkout/js/action/set-shipping-information'
],
function (quote, setShippingAction) {
    "use strict";

    return function (shippingMethod) {
        quote.shippingMethod(shippingMethod);
        // Update totals on summary
        setShippingAction([]);
    };
} 
);

Now it works!

0

I faced the same issue in Magento 2.2.6 version.

I tried the @chiriac answer but it will stop the whole checkout process for guest users.

You can use as below:

define([
    '../model/quote',
    'Magento_Checkout/js/model/cart/totals-processor/default'
], function (quote, totalsDefaultProvider) {
    'use strict';

    return function (shippingMethod) {
        console.log("select shipping methods");
        quote.shippingMethod(shippingMethod);
        totalsDefaultProvider.estimateTotals(quote.shippingAddress());

    };
});

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.