I have setup payment gateway and cash on delivery as payment methods on my magento site. Here there are two cases for product workflow.

Case 1: When payment is done by credit/debit card. Order status will change as Order confirmed-> payment received->pending->Invoiced->shipped->completed.

Case 2: When payment is done using COD method, order status will change as Order confirmed->pending->Invoiced->shipped->Payment pending->payment received->completed.

Can somebody help to setup this workflow in magento.?


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:

$installer = $this;

// new status details
$data = array(
    array('status' => 'new_status', 'label' => 'New Status')

// add new status to the relevant table
    array('status', 'label'),

// 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
    array('status', 'state', 'is_default'),

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.

|improve this answer|||||
  • @jonathan-hussay I have add a new order status using Adminpanel > System> Order staus> Create new status. And apply that status to Order state using Order Status>Assign Status to State. Coding suggested by you also doing the same thing but programming way. But I can not control the workflow of orders. e.g. See the workflow for this link. link. How can I edit this complete magento workflow of any orders with above two cases mentioned in my question? – Jenish Shivshaktiwala Sep 14 '14 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.