5

I want to get shipping method in my observer after placing an order. I am using sales_order_save_after event, so after place an order I want to get shipping method. I am getting shipping description but that is not enough for me. I want shipping method only but it's not returning shipping_method in response.

Please help me how to get shipping method in this situation?

2 Answers 2

16

You can get the shipping method by

$order->getShippingMethod();

or

$order->getShippingAddress()->getShippingMethod();
8
  • 1
    it's not working. Are you sure ? I am using sales_order_place_after event , in that it's not returning shipping method. Is there any other way ?
    – BornCoder
    Jan 18, 2017 at 12:10
  • 1
    try $order->getShippingAddress()->getShippingMethod() Jan 18, 2017 at 12:13
  • $order->getShippingMethod(); is working. Thanks
    – BornCoder
    Jan 18, 2017 at 12:16
  • Are you using \Magento\Framework\Event\Observer $observer and $order = $observer->getEvent()->getOrder(); ? I get Uncaught Error: Call to a member function getShippingMethod() on null
    – Gediminas
    Sep 27, 2017 at 10:58
  • I use payment_method_is_active event to disable payment method.
    – Gediminas
    Sep 27, 2017 at 11:41
7
$order->getShippingDescription(); // returns Shipping Method Title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.