• USD
  • Portuguese

How to Get Payment Method From an Order in Magento 2?

How to Get Payment Method From an Order in Magento 2?

Most vendors assume that their work ends once the customer has placed the order. However, it is not the case. The post-purchase is equally important as the purchase decision. This is why the top eCommerce experts recommend sending follow up messages to customers, obtaining their feedback, and working to streamline the post-purchase journey.

As soon as the customer completes the purchase, they are redirected to a ‘Thank You’ page. From the store owner’s perspective, this is the happiest moment. To ensure that the feeling is mutual on the customer’s side, it is recommended that the page should display the maximum information about the order(s). Research confirms that it contributes to a better shopping experience.

Customers should be able to see all the relevant order details at any point during or after the checkout. For example, if a customer wants to see the shipping charges or the payment method, he/she has chosen or any order information for that matter, it should be available in the Cart page, My Orders section, or on the ‘Thank You’ page. Unfortunately, it is nowhere to be seen.

The order information available in the default Magento 2 My Orders section or on the ‘Thank You’ page is very limited. If you want to add custom order details, you have to do it programmatically. Here, we are going to see how to view Magento 2 purchase order payment method. You may require this for multiple reasons. It all depends upon the nature of your business and customer’s requirements.

Reasons to Display Detailed Order Information

There are several reasons you should consider setting up the Magento 2 get payment method code from order feature. Firstly, it can help build trust as customers can easily check if they entered the correct information. Secondly, customers can ask for rectifications right away rather than have the order processed with incorrect information which is inconvenient for the store and the customer. Thirdly, customers don’t have to engage your support team to ask queries related to their payment. This ensures your support team is free to handle queries that really require their input.

How To – Magento 2 Get Payment Method from Order

Following is the code to get the payment model from the order, and then get the method instance from the payment:
$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();

Where $order is an instance of Magento\Sales\Model\Order.

Conclusion

That’s all for this tutorial. Please don’t hesitate to contact us in case of any question related to this tutorial.

Related Articles:

This blog was created with FME's SEO-friendly blog