I need to update checkout summary with shipping price by default when only one shipping method is available on shipping step. Currently shipping price is updated when I move on to payment step.

If someone can help then it will helpful, thanks in advance.

enter image description here

enter image description here


After some research got the solution to set shipping price to summary on checkout if there is only one shipping method available.

For this, need to extend "/vendor/magento/module-checkout/view/frontend/web/js/view/summary/shipping.js"

Have to define 'Magento_Checkout/js/model/cart/estimate-service' and pass dependency estimateService into function.

Comment out this line var price = this.totals().shipping_amount; under function getValue: function() and add following two lines after that.

var shippingMethod = quote.shippingMethod();
var price =  shippingMethod.amount;

I am adding screen shot of entire file /module-checkout/view/frontend/web/js/view/summary/shipping.js how it looks after extending and editing.

enter image description here

| improve this answer | |
  • if have 2 shipping method, how to fix it? thank you @SachinBhave – niceonelee Apr 28 '18 at 21:17
  • this should be accepted as the answer. I had the same problem and this saved my time. – Magento Learner Jun 19 '19 at 13:14

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.