Magento Themes and Magento Extensions

Magento: Change order status programmatically

Share

Change order status programmatically inĀ Magento

Load an order using the following code

$order = Mage::getModel('sales/order')->load($orderId);

OR
$incrementId = 1000002;
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);

Change order status:

Change the state of the loaded order using:

$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true);
$order->save();

Following is a list a possible states:

Mage_Sales_Model_Order::STATE_NEW
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
Mage_Sales_Model_Order::STATE_PROCESSING
Mage_Sales_Model_Order::STATE_COMPLETE
Mage_Sales_Model_Order::STATE_CLOSED
Mage_Sales_Model_Order::STATE_CANCELED
Mage_Sales_Model_Order::STATE_HOLDED

Comments are closed.