1

Is it possible in Magento to ship single items of an order independently of each other programatically?

For example, say i have an order with 5 order items and i want to ship only 1 of those how can this be done?

Additionally, i would like to determine if any of the single items has been shipped.

13

Yes, it's possible.

Manually

Go to the order, generate shipment, and then enter the # of qty/items to ship in that particular shipment.

enter image description here

The order will remain in Processing or your custom status until all items have been shipped before it will be marked as Completed.

Programmatically

$shipment = Mage::getModel('sales/service_order', $order)->prepareShipment(
    array(
      'order_item_id'=>1,
      'order_item_id'=>4,
      'order_item_id'=>2
    )
);

There are several ways to check if an item has been shipped

1) Look at the order item's qty_shipped value:

foreach($order->getAllItems() as $item){
    echo $item->getQtyShipped();
}

2) Look at the order item status:

$item->getStatus();

To get more information on how a status is determined (it's not a stored value, it's derived) see this class:

https://github.com/LokeyCoding/magento-mirror/blob/magento-1.7/app/code/core/Mage/Sales/Model/Order/Item.php#L194


More reading about generating shipments programmatically:

Programmatically Creating Shipments

  • Sorry, this is my mistake. I would like to do this in code – Marty Wallace Aug 27 '13 at 21:11
  • I have updated the question to avoid any future confusion. Sorry for that – Marty Wallace Aug 27 '13 at 21:11
  • See my edit to the answer. – philwinkle Aug 27 '13 at 21:15
  • Let's see how long it takes to flush out the downvoter. Care to explain? :) – philwinkle Aug 27 '13 at 22:49
  • @philwinkle I didn't got the screen which you answered in community edition, Am I doing anything wrong? – Anurag Khandelwal Jul 31 '17 at 7:48

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.