2

I'm using an extension which cancels an order after X days old. However, customers are not being notified about it. See my code:

if($order_bis->canUnhold()) {
    $order_bis->unhold()->save();
}
if ($order_bis->canCancel()) {
    Mage::log( '[kinento-reminder] Canceling order '.$order_bis->getIncrementId().' ('.$cancelprepaid->getTimestamp().' > '.$orderdate.')', null, 'kinento.log', true );
    $order_bis->cancel();
    $order_bis->addStatusToHistory($order_bis->getStatus(), 'Cancelado automaticamente', true);
    $order_bis->save();
    Mage::getSingleton( 'adminhtml/session' )->addSuccess( Mage::helper( 'reminder' )->__( 'Order %d canceled', $order_bis->getIncrementId() ) );
}

Is there something wrong here?

1 Answer 1

2

Add below after $order_bis->save() add below code

 $order_bis->sendOrderUpdateEmail($notify=true, $comment='Cancelado automaticamente');

This code is sending order update email.

5
  • Great, I'll try it, thanks. Just a doubt: in the history comments on the order page, the same comment was added twice by the module. So, that line "$order->cancel()" adds a comment automatically? Feb 27, 2015 at 18:35
  • just remove $order_bis->addStatusToHistory($order_bis->getStatus(), 'Cancelado automaticamente', true);
    – Amit Bera
    Feb 27, 2015 at 18:37
  • Done! So now I will wait until a new pending order to be cancelled. Do you know some online reference where I can find all order functions? Feb 27, 2015 at 18:40
  • And also, let's see if you can help me with something else: I would like to use a custom email template for cancelled orders and not just the order update email. Do you know how to? Feb 27, 2015 at 18:45
  • Please accept this answe
    – Amit Bera
    Feb 27, 2015 at 18:48

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.