0

I'm developing an observable that listen to the sales_order_save_after event.

I have the order information executing $observer->getEvent()->getOrder() but i cannot get the payment method selected (cash on delivery or check/money order, etc).

I did try with $order->getPayment()->getMethod() but this works only when the order already has been payed. (And I need to know what payment method was selected when the order was placed).

Thanx in advance

1
  • $payment = $order->getPayment(); $method = $payment->getMethod(); Nov 26, 2021 at 4:56

2 Answers 2

1

Please use below code in your Observer to get payment method data

Method 1

$payment = $order->getPayment();
$method = $payment->getMethodInstance();
$methodTitle = $method->getTitle();
//print_r($method->getData());

Method 2

$order->getPayment()->getAdditionalInformation("method_title")
2
  • I've made it work with the approach that you have proposed and changing the sales_order_save_after to sales_order_place_after, thnx
    – Charppi
    Nov 26, 2021 at 19:17
  • glad to know .. It's helped you :) Nov 27, 2021 at 17:07
0

You can try below to get the payment method from the order.

$payment = $order->getPayment();
$method = $payment->getMethodInstance();
$methodTitle = $method->getTitle();

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.