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, Continue reading “Count total shipment for an order by order id Magento 2.”

Delete Shipment by shipment id Magento 2.

You can delete the Specific Shipment data by shipment id in Magento 2.

Using Magento\Sales\Api\ShipmentRepositoryInterface interface, you need to use delete() method to delete shipment data from the shipment table.

You must first fetch the Shipment object by id and then pass the Shipment object as a parameter in delete() method to delete specific Shipment. Continue reading “Delete Shipment by shipment id Magento 2.”

Get Shipment details by shipment id Magento 2.

You can get the Shipment collection data for the specific shipment by shipment id in Magento 2.

Using Magento\Sales\Api\ShipmentRepositoryInterface interface, you need to use get() method to fetch shipment data by its id.

Pass shipment id as get method, get($shipmentId) arguments.

When you check the sales_shipment table, You can get the result of all the field value with a specific id. Continue reading “Get Shipment details by shipment id Magento 2.”