By default you can't adjust the order state when it's complete. This is because this state is protected.
A closer look at the code tells us why:
When you call setState the following is triggered in the Mage_Sales_Model_Order
class.
public function setState($state, $status = false, $comment = '', $isCustomerNotified = null)
{
return $this->_setState($state, $status, $comment, $isCustomerNotified, true);
}
Which, as you can see bubbles directly down to _setState
.
protected function _setState($state, $status = false, $comment = '',
$isCustomerNotified = null, $shouldProtectState = false)
{
// attempt to set the specified state
if ($shouldProtectState) {
if ($this->isStateProtected($state)) {
Mage::throwException(
Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state)
);
}
}
$this->setData('state', $state);
// add status history
if ($status) {
if ($status === true) {
$status = $this->getConfig()->getStateDefaultStatus($state);
}
$this->setStatus($status);
$history = $this->addStatusHistoryComment($comment, false); // no sense to set $status again
$history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility
}
return $this;
}
In which all states that are passed in are checked using the isStateProtected
method.
Check that method tells us that the 'complete' state is protected. Thus is being blocked for further updates.
public function isStateProtected($state)
{
if (empty($state)) {
return false;
}
return self::STATE_COMPLETE == $state || self::STATE_CLOSED == $state;
}
When an order is complete, usually it's invoiced and shipped etc. So why would you want to adjust the state back to 'processing'? That would mean the order is not shipped anymore, while a shipment is probably already created. That will probably give you some trouble further down the road.
For now at least you know why you can't adjust the order. Hopefully this helps you!
I can give you an example how to add additional status to existed payment method.
Magento by default in system / configuration has such as 'New Order Status'.
Let's look at SavedCC:
Now we change system.xml file.
Original:
<order_status translate="label">
<label>New Order Status</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_order_status_new</source_model>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</order_status>
You need to replace
<source_model>adminhtml/system_config_source_order_status_new</source_model>
with:
<source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>
And you will get:
Best Answer
Take a look at http://www.mexbs.com/magento-order-statestatus-flow/
Order "Pending" From the Admin panel, the sales order appears in the Order list as "Pending". At this point, payment has not been processed, and the order can still be canceled.
Payment Received The status of the order remains "Pending" until payment is received. Depending on the payment method, you, may be notified when the transaction is authorized and in some cases, processed. The status of the order is now "Processing" and order can not be cancel and you will need to issue a credit using Credit Memos see http://www.magentocommerce.com/knowledge-base/entry/order-process-overview