Change Order Confirmation Email for Specific Orders in Magento

email-templatessales-order

I have two 'special' products that when ordered should send a custom email (in place of the standard order confirmation email).

An Observer is set up for the sales_order_place_after event but not sure how to change the email template for the order.

How do I change the email template for this particular order.

Best Answer

To send different order conformation email depending on specific criteria you would either have to :

  1. Rewrite sendNewOrderEmail() in Mage_Sales_Model_Order and add logic to check the template

  2. Disable magento "order confirmation email" in system config, then create a custom module to send your email by coping logic from sendNewOrderEmail() using event/observer

  3. For simple text changes, you could use template logic {{if order.customer_group_id}} or {{depend order.customer_group_id}} but they seem to only evaluate true/false condition, therefore for more advance logic you could include a block

{{block type='core/template' area='frontend' template='sales/custom_logic.phtml' order=$order}}

In custom_logic.phtml

<?php
  $order = $this->getOrder()

  if($order->getCustomerGroupId() == 1){
     ///do
   ....

See Magento Email Template If Statements

Related Topic