1

I'm trying to change status of order as hold by calling an observer on sales_order_place_after event. When I log the order object, it shows that order status has been set to 'hold' but when I check order status after thank you message. It is again set to 'new'.

Which event should I use to change order status on placing an order.

  • basically do you need to set all new orders status to hold status ? – Pradeep Sanku Jul 7 '16 at 14:53
  • Not all, but some specific orders and i'm doing that logic on observer and if that order belongs to some specific category, then i want to set its status as on hold @PradeepSanku – Arun Pal Jul 7 '16 at 15:02
0

try to change the order status to hold after thank you message displays. for this use checkout_onepage_controller_success_action event to change the order status.

<events>
    <checkout_onepage_controller_success_action>
        <observers>
            <change_order_status>
                <class>YourPackageName_YourModuleName_Model_Observer</class>
                <method>changeOrderStatus</method>
            </change_order_status>
        </observers>
    </checkout_onepage_controller_success_action>
</events>

and function is as follows

class YourPackageName_YourModuleName_Model_Observer{
    public function changeOrderStatus($observer){
        $orderIds = $observer->getEvent()->getOrderIds();
        foreach ($orderIds as $orderId) {
            $order = Mage::getModel('sales/order')->load($orderId);
            $quoteId = $order->getQuoteId();

            // this is how we get quote id from order.
            // now add your logic here for shortlisting orders to be made on hold
        }
    }
}
  • But I need quote id as well to do some logical task to decide which order status has to be set as 'on hold' and quote Id is not available at success event. @PradeepSanku – Arun Pal Jul 7 '16 at 18:01
  • WARNING: checkout_onepage_controller_success_action might not always fire, when the customer is exiting the browser to early, the order might already be in the database but the status is not updated – Alex Jan 9 at 10:27

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.