I think that's because the delivered status is set after the order is shipped, which makes the order complete. To remove this behavior, you need to comment or remove this line in app/code/core/Mage/Sales/Model/Order.php:
$this->_setState(self::STATE_COMPLETE, true, '', $userNotification);
You can find it in the function _checkState()
, which is called just before the order is saved.
Having said that, it is a big NO-NO to modify core file directly. You have to bear all the risks that come with it.
When dealing with the orders you actually have both status
and state
. status
is the label you see against the order telling you, well it's status, but the state
defines what actions can be performed against that order. You are probably only going to need to use a new status
as the existing states cover most scenarios. You can add a new state using a data install script for your module:
<?php
$installer = $this;
// new status details
$data = array(
array('status' => 'new_status', 'label' => 'New Status')
);
// add new status to the relevant table
$installer->getConnection()->insertArray(
$installer->getTable('sales/order_status'),
array('status', 'label'),
$data
);
// data associating new status with existing state
$data = array(
array('status' => 'new_status', 'state' => 'holded', 'is_default' => 0)
);
// add association data to the relevant table
$installer->getConnection()->insertArray(
$installer->getTable('sales/order_status_state'),
array('status', 'state', 'is_default'),
$data
);
When you have done the above to create each new order status you will probably want to do something along the lines of use save observers on invoice/shipment creation to modify the order state. You can do this very simply once you have the order object using:
$order->setState($state, $status, $comment, $notifycustomer)->save();
$state
should be the order state, $status
is optional and can be the new status
you created, but it can also be true
to use the default status
for the state
. $comment
is optional and should be any comment you want to add to the order, and $notifycustomer
is optional and should be true
or false
(default) according to whether you want to notify the customer about the status
change.
Best Answer
For achieve thing you need to understand magento Default order Flow:
Please check the below image for understand magento order flow
As per as my thought,You need to do coding for achieve this thing also
need to create Some Order status basic of some Order state
.For create those You need to go admin>System>Order statuses.Order status : new > processing > ready to deliver > delivered
or
For cod: new > processing > ready to deliver > pending payment > delivered
New: Make very payment method New Order Status=Pending[]
Processing: As per as,magento if you create invoice or Shipment of new order then order status goin to process and state goes to processing.
Ready to deliver or pending payment : you need to create new status for state:Processing. and manage this status status depend on payment method,you must need customization. Prevent to stop order status order complete whenever order is already invoice or ship.
Delivered: For manage "delivered",you need to Make new Status delivered to state complete.And make Status delivered as default for state complete