How To Get Payment Method Title Of Order In Magento 2
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:
1 2 3 4 5 6 |
$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
.
That’s it.
Please use the Comments section below to mention any doubts on the topic and I’d help you out.
I’ll be grateful if the readers will help share the solution with Magento community via social media platforms 🙂
Thank you.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
4 Comments
Hello Sanjay, Does this method work for Magneto 2.4.4 where many things have changed?
Hello Sam,
You can try the same by applying the below method:
$payment->getAdditionalInformation();
Thank You
Hello
Can we also get the additional payment information separately?
Thanks
Aldo
Hello,
You can use:
$order->getPayment()->getAdditionalInformation(); to get additional payment information
Thank you.