5

How do I change the order status? I do orders that are sometimes picked up and delivered (not just shipped) so I need to change the order statuses to "picked up" and "delivered"

How do I do that? I already created these statuses in the config area.

2 Answers 2

9

Below are the status's you can use

const STATE_NEW             = 'new';
const STATE_PENDING_PAYMENT = 'pending_payment';
const STATE_PROCESSING      = 'processing';
const STATE_CLOSED          = 'closed';
const STATE_CANCELED        = 'canceled';
const STATE_HOLDED          = 'holded';
const STATE_PAYMENT_REVIEW  = 'payment_review';

Code for updating the status.

$order = Mage::getModel('sales/order')->load($orderid, 'increment_id');
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
$order->save();

Above code will update all the status's except COMPLETE Status. As Order becomes complete only when invoice and shipment is created. Once invoice and shipment is created order will automatically changed to Complete.

so for that you can use below code.

Create Invoice

$invoice = $order->prepareInvoice()
                 ->setTransactionId($order->getId())
                 ->addComment($comment)
                 ->register()
                 ->pay();

$transaction_save = Mage::getModel('core/resource_transaction')
                 ->addObject($invoice)
                 ->addObject($invoice->getOrder());
$transaction_save->save();

create shipmnet

$itemQty =  $order->getItemsCollection()->count();
$shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($itemQty);
$shipment = new Mage_Sales_Model_Order_Shipment_Api();
$shipmentId = $shipment->create($orderId);
1
  • 1
    State and Status are not the same thing within Magento - ka.lpe.sh/2012/04/21/magento-order-state-vs-status
    – mikemike
    Mar 30, 2015 at 15:30
3

Rather than give you code I prefer to handle this from the admin panel:

  1. Log into the admin panel and navigate to the order in question: Sales > Orders
  2. Scroll down to the bottom of the order detail and take note of the order comments box:

    enter image description here

    The dropdown displays statuses that are applicable to the current order state. To input new available statuses edit the status/state association in the configuration panel: System > Order Statuses.

  3. Input a comment with a new status and click "Submit Comment" - the order status will change to the selected status.

1
  • I think that's pretty obvious from my post that they're two different things.
    – philwinkle
    Mar 30, 2015 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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