1

I added 2 more status for the orders, and I would like to automatically send transactional email when the orders reach this status.

I added the Email templates, but have no idea what I have to do to automatically send these emails.

1

1 Answer 1

2

I managed to do it !

If it can help somebody, here is my Observer.php

<?php
class Mine_Custmail_Model_Observer
{
    public function invoicedStatusChange($event)
    {
        $order = $event->getOrder();
        $orderStatus = $order->getStatus();

        /*if ($order->getState() == Mage_Sales_Model_Order::STATE_CANCELED)*/
        if ($orderStatus == 'waitingmanufacturing')
            $this->_sendStatusMail($order);
    }

    private  function _sendStatusMail($order)
    {
        $email = Mage::getModel('core/email_template');
        $sender  = array(
                'name' => Mage::getStoreConfig('trans_email/ident_sales/name', Mage::app()->getStore()->getId()),
                'email' => Mage::getStoreConfig('trans_email/ident_sales/email', Mage::app()->getStore()->getId())
            );
        $customerName = $order->getShippingAddress()->getFirstname() . " " . $order->getShippingAddress()->getLastname();
        $customerEmail = $order->getPayment()->getOrder()->getCustomerEmail();
        $customerLanguage = $order->getStoreId();

         if ($customerLanguage == 1)
         {$template = 12;}
         else {$template = 13;}

        $vars = Array( 'order' => $order );

        $storeId = Mage::app()->getStore()->getId(); 

        Mage::getModel('core/email_template')->sendTransactional($template, $sender, $customerEmail, $customerName, $vars, $storeId);

    }
}
0

Your Answer

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

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