Get Payment Method

How to Get the Payment Method Title of an Order in Magento 2?

If you really want to succeed in the eCommerce business, you’ll have to pay extra attention to even the smallest details like the color of a button or text on the Thank You page.

This is especially important because such one-minute details contribute a lot towards improving the user experience of your eCommerce store.

And today, we’re going to talk about one such 1-minute detail, which is to get the payment method title of order in your Magento 2 store.

In any eCommerce store, what information you display on the My Orders page is quite critical because it’s a part of the post-shopping experience.

And unfortunately, Magento 2 does not display the payment method title of the order by default on the My Orders page.

However, there is a simple solution you can implement to get the payment method title of the order to be displayed on the My Orders page of your customers.

The Process to Get Payment Method Title of Order in Magento 2

To get the payment method title of the order, first, you’ll have to get the payment model from the order and then get the payment method instance by using the following code:

$orderIncrementId=10000003;

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$order = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($orderIncrementId)

$payment = $order->getPayment();

$method = $payment->getMethodInstance();

$methodTitle = $method->getTitle();

Here, $order is an instance of Magento\Sales\Model\Order

And that’s about it!

Conclusion

This is how you can get the payment method title of order in Magento 2.

And if you need our professional assistance, feel free to contact us at any time.

Tags