How to get Shipment Increment ID by Order ID in Magento

Viewed 14411

Hello Guys. Can someone tell me how to get the shipment increment id by order id in Magento ?

I need this because I use an outside php file to add tracking information to a shipment and it needs the shipment id for this.

Thank you for all your help.

I am using the code below to add tracking info

$shipmentIncrementId='300000002';
$trackNumber='123456';
$carrier='custom';
$title='server10';


$shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($shipmentIncrementId);

         /* @var $shipment Mage_Sales_Model_Order_Shipment */



         $track = Mage::getModel('sales/order_shipment_track')
                     ->setNumber($trackNumber)
                     ->setCarrierCode($carrier)
                     ->setTitle($title);

         $shipment->addTrack($track);

         try {
             $shipment->save();
         } catch (Mage_Core_Exception $e) {
             $thiss->_fault('data_invalid', $e->getMessage());
         }

         return $track->getId();

print_r($shipment);
1 Answers
Related