Order State and Status in Magento

Many of you might have come across the requirement, where they needed to change the order status dynamically.

Difference between order state and status
State is used by Magento to tell if the order is new, processing, complete, holded, closed, canceled etc.; while Statuses are the one that YOU would be defining at the back-end in System -> Order Statuses. Magento displays order STATUSES and not STATES in the back-end order detail page to let you know which status is assigned as per your mapping. Remember, multiple statuses can be mapped with one state, while vice verse is not possible.

Please check this file /app/code/core/Mage/Sales/etc/config.xml (I have refered Magento 1.4)

Also refer this in Magento Wiki Order Management

                    <pending translate="label"><label>Pending</label></pending>
                    <pending_payment translate="label"><label>Pending Payment</label></pending_payment>
                    <processing translate="label"><label>Processing</label></processing>
                    <holded translate="label"><label>On Hold</label></holded>
                    <complete translate="label"><label>Complete</label></complete>
                    <closed translate="label"><label>Closed</label></closed>
                    <canceled translate="label"><label>Canceled</label></canceled>
                    <fraud translate="label"><label>Suspected Fraud</label></fraud>
                    <new translate="label">
                            <pending default="1"/>
                    <pending_payment translate="label">
                        <label>Pending Payment</label>
                            <pending_payment default="1"/>
                    <processing translate="label">
                            <processing default="1"/>
                    <complete translate="label">
                            <complete default="1"/>
                    <closed translate="label">
                            <closed default="1"/>
                    <canceled translate="label">
                            <canceled default="1"/>
                    <holded translate="label">
                        <label>On Hold</label>
                            <holded default="1"/>

I am displaying here the code to change the state and status of the order dynamically

Before modifying order status in some code, make sure that current order state allows status wanted. It is possible to change both state and status with setState method

$orderId = 3226; //order id
$order = Mage::getModel('sales/order')->load($orderId); //load order				
$state = 'complete';
$status = $state;
$comment = "Changing state to $state and status to $status Status";
$isCustomerNotified = false; //whether customer to be notified
$order->setState($state, $status, $comment, $isCustomerNotified);	
//$order->setStatus($status);	//can also use this to change only status
try { 
echo "<br />State and Status Updated";

}catch (Exception $e)
	echo $e->getMessage();

Hope its useful.

Also I found this useful

5 thoughts on “Order State and Status in Magento

  1. Thanks! Now I understand the difference between states and statuses. I’m new to Magento and I’m trying to read about this platform.
    If I need to change order status, should I do it programmatically? Or is it better to use some extensions (like order status by Amasty, I’ve just found it while researching this topic)? Please share you thoughts.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top