How to modify order email template based on store id in multi stores

By | April 21, 2017
Spread the love

If any merchant running multi store magento websites then every time they needs to send different email format for each store.

Lets see how we can add some depends conditions based on store ids. You cannot use logical expressions in depend (unfortunately neither in if as one comment suggested). So the only way I see to achieve what you are trying is to add variables. For example:

You can set more template variables in app\code\local\Mage\Sales\Model\Order.php in function

public function queueNewOrderEmail($forceMode = false)

// Set all required params and send emails
        $mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
        $mailer->setStoreId($storeId);
        $mailer->setTemplateId($templateId);
        $mailer->setTemplateParams(array(
            'order'        => $this,
            'billing'      => $this->getBillingAddress(),
            'payment_html' => $paymentBlockHtml,
        		
            'store_1'	=> ($storeId == 1),
            'store_2'	=> ($storeId == 2)
        ));

Template file: app\locale\en_US\template\email\sales\order_new.html

<!–@subject {{var store.getFrontendName()}}: New Order # {{var order.increment_id}} @–>
<!–@vars
{“store url=\”\””:”Store Url”,
“var logo_url”:”Email Logo Image Url”,
“var logo_alt”:”Email Logo Image Alt”,
“htmlescape var=$order.getCustomerName()”:”Customer Name”,
“var store.getFrontendName()”:”Store Name”,
“store url=\”customer/account/\””:”Customer Account Url”,
“var order.increment_id”:”Order Id”,
“var order.getCreatedAtFormated(‘long’)”:”Order Created At (datetime)”,
“var order.getBillingAddress().format(‘html’)”:”Billing Address”,
“var payment_html”:”Payment Details”,
“var order.getShippingAddress().format(‘html’)”:”Shipping Address”,
“var order.getShippingDescription()”:”Shipping Description”,
“layout handle=\”sales_email_order_items\” order=$order”:”Order Items Grid”,
“var order.getEmailCustomerNote()”:”Email Order Note”}
@–>
<!–@styles
@–>

{{depend X}}...{{/depend}} output content in between only if variable X is true-ish (note that you cannot use logical expressions here, just variables or methods on variables.

{{depend store_1}}
  add your text here
{{/depend}}
{{depend store_2}}
  add your text here
{{/depend}}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

20 + 9 =