How to Check if Magento 2 Order is Invoiced or Shipped
The internet has changed how people shop. Moreover, varied methods of payments, shipping has even made the traditional online shopping more customized in order to increase sales and more importantly, customer experience!
However, with such advances, the old age process of placing an order, payment, invoicing and then the shipment may be invalid in some cases. For example, cash on delivery option needs the order to be first shipped, and then the invoice is generated!
To implement the out of way function in Magento 2 store, the foremost requirement is to check the status of an order. You need to check if Magento 2 order is invoiced or shipped and the post tells you how to do so!
Check if Magento 2 Order is Invoiced:
1 2 3 |
if ($order->getInvoiceCollection()->count()) { //do your stuff here } |
1 2 3 |
if($order->hasInvoices()){ //do your stuff here } |
Check if Magento 2 Order is Shipped:
1 2 3 |
if ($order->getShipmentsCollection()->count()) { //do your stuff here } |
1 2 3 |
if ($order->hasShipments()) { //do your stuff here } |
Use the Comments section below to give your opinions or ask any doubts on the topic.
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.
Prev
How to Add New Column in Magento 2 Quote Table & Order Table
How to Set Default Values for Magento 2 System Configuration
Next