2

I created a new status on admin panel for orders.

System -> order status -> create new status

I created the status for cash on delivery payment option.

While the order processing, how can i track the payment method and update the table sales_flat_order status column with cash on delivery as status. My status code is cod

  • are want assign the order status code to CASH on delivery orders – Amit Bera Jan 7 '15 at 11:17
  • yes i want to check the payment method and if the method selected by the customer is cash on delivery then only i want to update the sales_flat_order table's status in to cod which i already created. – Mujahidh Jan 7 '15 at 11:19
1

Mujas,you can do this by magento event observer.

Fire an observer on event checkout_submit_all_after and change order status your New Order status.

event Config.xml code look like

<global>
    <events>
        <checkout_submit_all_after>
            <observers>
                <change_order_status>
                    <class>yourmodule/observer</class>
                    <method>CodeOrdeStatus</method>
                </change_order_status>
            </observers>
        </checkout_submit_all_after>
    </events>
</global>

Observer code look like:

public function CodeOrdeStatus($observer)
{
    $order = $observer->getEvent()->getOrder();
    $order = Mage::getModel('sales/order')->load($order->getId());
    // check order is code or not
    if($order->getPayment()->getMethodInstance()->getCode() == "cashondelivery") {
        $order->setStatus("complete");
        $order->save();    
    }
}
  • @Amith Bera Thank you for your time,I will try and update the status – Mujahidh Jan 7 '15 at 11:31
  • I worked on your idea.For the completeness of the answer i have to Create main module xml file also. and this line if($order->getPayment()->getMethodInstance()->getCode()=="cod"): the payment method should be "cashondelivery" instead of "cod". for future users easy i just mention here add the <events> tag in to <global> tag in your config.xml file. Thanks Amith Bera You save my time. – Mujahidh Jan 8 '15 at 7:39
  • Hi Amith, glad if you can help me in this question. magento.stackexchange.com/questions/51957/… – Mujahidh Jan 13 '15 at 7:21

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.