An E-commerce store demands attention to even small details like the color of a button or details in the Thank you page or showing what order information!
It is because every step plays a role either in pushing the user towards conversion or improving customer experience.
One such minute detail is to get payment method title of order in Magento 2, and make a payment method visible only to admin.
What order information you are going to display in My Orders section of Magento 2 matters as a part of the post-shopping experience. It should not happen that when a customer checks the My Orders section to find any information about the order, it is missing.
However, the default Magento 2 does not include all the order payment information in Magento 2.
Therefore, the below solution allows the admin to get payment method title of order in Magento 2. Keep in mind the nature of your business and customer insights to decide if you need to add the order payment information in Magento 2 store or not.
Method To Get Payment Method Title Of Order In Magento 2:
Get the payment model from the order, 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 MagentoSalesModelOrder
.
That’s it.
I’ll be grateful if the readers will help share the solution with Magento community via social media platforms
Thank you.