0

In Magento 2, I try to change the shipping method for orders programmatically.

I did this

$order->setShippingMethod('my_new_method');
$order->save();

The shipping_method attribute is changing as expected, but I also need to recalculate order shipping prices according to the new method.

Do you know how to do it?

3
  • you need to recalculate the total as well with this one. – Dhiren Vasoya Apr 2 at 14:08
  • @DhirenVasoya Is there a method to call that automatically recalculates all amounts? – Fbr Apr 2 at 14:48
  • What's your use case, including the point in the order process that you need this to happen? – kookaburra Apr 2 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.