Below is a php code to create a shipment for an order in magento.
$order = Mage::getModel('sales/order')->loadByIncrementId('100000001');
try {
if($order->canShip()) {
//Create shipment
$shipmentid = Mage::getModel('sales/order_shipment_api')
->create($order->getIncrementId(), array());
//Add tracking information
$ship = Mage::getModel('sales/order_shipment_api')
->addTrack($order->getIncrementId(), array());
}
}catch (Mage_Core_Exception $e) {
print_r($e);
}
$order = Mage::getModel('sales/order')->loadByIncrementId('100000001');
try {
if($order->canShip()) {
//Create shipment
$shipmentid = Mage::getModel('sales/order_shipment_api')
->create($order->getIncrementId(), array());
//Add tracking information
$ship = Mage::getModel('sales/order_shipment_api')
->addTrack($order->getIncrementId(), array());
}
}catch (Mage_Core_Exception $e) {
print_r($e);
}
No comments:
Post a Comment