Magento 2 check if order has invoiced or shipped

If you want to check the order has invoiced or shipped. Please follow the below Magento 2 check if order has invoiced or shippedcode:

You can use this code for checking order has invoiced:
if ($order->getInvoiceCollection()->count()) {
    // Invoice exist
}
or
if($order->hasInvoices()){
   // Invoice exist
}
You can use this code for checking order has shipped:
if ($order->getShipmentsCollection()->count()) {
    // Shipment exist
}
or
if($order->hasShipments()){
   // Shipment exist
}

Please leave your comment for asking any question or suggestion.

Need Help?

Magento 2 check if order has invoiced or shippedexpoundsofttechsolution

Magento 2 check if order has invoiced or shipped