Count total shipment for an order by order id Magento 2.

You can count the no. of Shipment generated for the specific order by order id in Magento 2.

Using Magento\Sales\Api\ShipmentRepositoryInterface interface you need to use getList() method with SearchCriteriaBuilder Object to add filter by order id.

Using Below code snippet, You can fetch the count of shipment for an order,

Using above code snippet you can get the shipment count for an order.

2  (Order with 2 shipments.)