I can successfully create the shipment for the entire order but if I want to create partial shipment then it will also create the full quantity can someone tell me how can I create the partial shipment.

2 Answers 2



Here is the way to create partial shipment.

you have to pass orderItemId and Qty to ship

Class ShipmentAPI{

    protected $_shipOrderInterface;

    public function __construct(
     \Magento\Sales\Api\ShipOrderInterface $shipOrderInterface
        $this->_shipOrderInterface = $shipOrderInterface;

    public function createShipment($orderId){

        $shipmentItems = [ "29" => 2 ];
        $shipmentId = 0;    
        if(count($shipmentItems) > 0){

            foreach($shipmentItems as $orderItemId => $qty){
                $itemCreation = $this->_shipmentItemCreationInterface;

                $shipItem[] = clone $itemCreation;              

            $shipmentItem = $this->_shipmentInteface->setItems($shipItem);

            $_items = [];
            if(count($shipmentItem->getItems()) > 0 ){
                $_items = $shipmentItem->getItems();    

            $shipmentId = $this->_shipOrderInterface->execute( 
                $notify = false,
                $appendComment = false,
                $comment = null,  

        return $shipmentId;

this function will give you shipmentId after passing the items properly. Hope this will help you.


A bit of a simpler solution that worked perfectly for me:

$shipmentItems = [

$this->shipOrder->execute($orderId, $shipmentItems, $notify, $appendComment, $comment, $tracks, $packages, $arguments);

Where $this->shipItemCreation is an instance of \Magento\Sales\Api\ShipOrderInterface and $this->shipOrder is an instance of \Magento\Sales\Api\ShipOrderInterface.

The above example creates a shipment with 1 unit of the order item ID 1234.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.