0

I am using Custom order status While changing it send a mail. It's working fine

$order->sendOrderUpdateEmail(true, null);

How to send custom email template(New Template) per status?

public function shipementorderAction(){
                $id = $this->getRequest()->getParam('id');

                $order = Mage::getModel('sales/order')->load($id);
                $order->setData('state', 'shipement');
                $order->setStatus('shipement');
                $history = $order->addStatusHistoryComment('', false);
                $history->setIsCustomerNotified(false);
                $order->save(); 

                $order->sendOrderUpdateEmail(true, null);

                $this->_getSession()->addSuccess(
                    $this->__('The order state has been changed.')
                );
                //$this->_redirect('mpshippingmanager/shipping/index');
                Mage::getSingleton('core/session') ->addSuccess('Order Updated Successfully'); $this->_redirectReferer();


                }
2
  • are you use custom email template in function $order->sendOrderUpdateEmail(true, null); or create new custom function : $order->sendOrderCustomStatusUpdateEmail(true, null);for email template?
    – Abdul
    Commented Dec 28, 2015 at 9:30
  • Check my update question i want to use custom function
    – Magento 2
    Commented Dec 28, 2015 at 9:42

1 Answer 1

2

I am not clear not about your question, may be you want to change Order update email template basic of one Custom order status

So,you need to rewrite class Mage_Sales_Model_Order and at queueOrderUpdateEmail() you need to do customize.

In default magento,on basic customer type (register/guest ) send different html template.see at line 1399 of that function

    // Retrieve corresponding email template id and customer name
    if ($this->getCustomerIsGuest()) {
        $templateId = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, $storeId);
        $customerName = $this->getBillingAddress()->getName();
    } else {
        $templateId = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_TEMPLATE, $storeId);
        $customerName = $this->getCustomerName();
    }

for you case,you need to set different email template of order status.

Follow the below steps

  • Create your email template and place it in template folder.For my case it was app\locale\Your_Language\template\email\sales. Suppose it's name is order_update_custom_order.html which is replicated of ** order_update.html**
  • Create your new module. Define email template at config.xml . <global> ... <template> <email> <order_update_custom_order module="sales"> <label>custom email module</label> <file>sales/order_update_custom_order.html</file> <type>html</type> </order_update_custom_order> </email> </template> ... </global>
  • then set this template basic of you custom order status at 1407 line

if($this->getStatus()=='Your_Custom_Order_status'); $templateId = 'order_update_custom_order'; endif;

5

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.