I have the following observer method thats been called successfully, but the order status is not changing.

public function customCancel(Varien_Event_Observer $observer) {

        $order = $observer->getEvent()->getPayment()->getOrder();
        $order = Mage::getModel('sales/order')->load($order->getId());
        $payment_code = $observer->getEvent()->getPayment()->getMethodInstance()->getCode();
        if ($payment_code == 'cashondelivery') {
            $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Cancel Transaction.');
            Mage::log($payment_code, null, 'paymentMethod.log');

I have implemented the following event.


  • Please add the magento-1 tag here
    – tread
    May 23, 2017 at 7:41

1 Answer 1


There's a lot more going on canceling an order than just simply set its state to canceled. Please try following code sections inside your if-block instead and see if at least one of them gets you there:

$order->registerCancellation('Cancel Transaction.', false);

false will throw an exception if the order is not subject to cancelation.

If this doesn't work for you, try


This one might cause trouble since it cancels the payment, too, to which your observer is listening so you might create an infinite loop. Maybe there's an event better suited for your situation.

  • Not working either of these options Nov 21, 2016 at 6:59

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.