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.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI 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.
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);
}
}