문제

I'd like to update shipping price and cart subtotal when choosing a different shipping method in the checkout page

enter image description here

Any hint on involved files and the right approach would be very helpful

올바른 솔루션이 없습니다

다른 팁

I've finally done it like this:

  • Create a require-config.js file in app/design/frontend/Vendor/Theme/Magento_Checkout/web/requirejs-config.js

require-config.js

var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/view/summary/abstract-total': {
                'js/view/summary/abstract-total-mixin': true
            },
            'Magento_Checkout/js/view/shipping': {
                'js/view/shipping-mixin': true
            }
        }
    }
};
  • Add the defined files in require-config.js which are:

app/design/frontend/Vendor/Theme/Magento_Checkout/web/js/view/summary/abstract-total-mixin.js

abstract-total-mixin.js

define([], function () {
    'use strict';

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

                return true;
            }
        });
    };
});

app/design/frontend/Vendor/Theme/Magento_Checkout/web/js/view/summary/shipping-mixin.js

shipping-mixin.js

define([
    'Magento_Checkout/js/model/cart/estimate-service'
], function (estimateService) {
    'use strict';

    var mixin = {
        initialize: function () {
            this._super();
        }
    };

    return function (target) {
        return target.extend(mixin);
    };
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top