3

Is it possible to use multiple footers for the Transactional Emails?

So I want to use a specific footer for a new order email, and an other footer for the shipment email.

I currently load the footer with this line: {{template config_path="design/email/footer"}}

How can I load a specific template in the transactional email?

10

There are two things to first understand about transactional emails:

  1. By default the templates are in app/locale/en_US/template/email where en_US is the locale code configured for the store.
  2. They can be loaded into the database and edited using an editor within the browser. If an override is done that way, they are no longer loaded from the filesystem.

So first decide, if you want to keep them loading from the file system (and thus be able to version them) or from the database (so the merchant can easily edit the layout).

The footer and header are special:

The template is configured via the system configuration System > Configuration > [General:Design] > Transactional Emails. By default it's set to "Default from locale" which refers to the file app/locale/en_US/template/email/html/footer.html.

To change the footer, you need to add a new template that is then stored in the database. Go to System > Transactional Emails. You'll get a screen that has a top section to load an already defined template as base and it's probably wise to load the default:

Load footer email

However, Magento assumes that there's a shared footer (and shared header) for all emails, so while you can change it, you cannot change it per email.

So, in this case, your best bet is to change the order_new.html template in app/code/locale/en_US/template/email/sales. Remove the {{template config_path="design/email/footer"}} and replace it with the HTML you want. This is the easiest way to override a footer for a specific template.

If you have different requirements, expand your question and we'll try to help you.

  • Thanks for you explanation! That is already what I thought, to edit the entire order_new.pthml. That will be the best solution! – Henk Z Jan 31 '15 at 14:30
6

Yes as you can begin a transactional email with ANY CMS static block.

So create a new CMS static block and then insert it on top of your email content like so.

{{block type="cms/block" block_id="email-header-sales" }}

The system configuration of "Email Header Template" is new to v1.9.x so just replace the reference to this configuration option with your new CMS static block.

{{template config_path="design/email/header"}}

This option just gives you the ability to create a entire new header and footer and then apply it globally.

  • I needed to allow cms/block under System -> Permissions -> blocks – Collin Anderson Oct 20 '17 at 20:25
0

You can also implement the class default Magento to work with multiple (headers and footers).

Create file:

app/local/Mage/Adminhtml/Model/System/Config/Source/Email/Template.php

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    Mage
 * @package     Mage_Adminhtml
 * @copyright  Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */


/**
 * Adminhtml config system template source
 *
 * @category   Mage
 * @package    Mage_Adminhtml
 * @author      Magento Core Team <core@magentocommerce.com>
 */
class Mage_Adminhtml_Model_System_Config_Source_Email_Template extends Varien_Object
{
    /**
     * Config xpath to email template node
     *
     */
    const XML_PATH_TEMPLATE_EMAIL = 'global/template/email/';

    /**
     * Generate list of email templates
     *
     * @return array
     */
    public function toOptionArray()
    {
        if(!$collection = Mage::registry('config_system_email_template')) {
            $collection = Mage::getResourceModel('core/email_template_collection')
            ->load();

            Mage::register('config_system_email_template', $collection);
        }
        $options = $collection->toOptionArray();
        $templateName = Mage::helper('adminhtml')->__('Default Template from Locale');
        $nodeName = str_replace('/', '_', $this->getPath());

        // Implementation for various templates config.
        $templatesNodes = Mage::app()->getConfig()->getNode('global/template/email');
        if(count($templatesNodes)) {
            foreach($templatesNodes as $nodes) {
                foreach($nodes as $code => $config) {
                    if(strpos($code, $nodeName) !== false) {
                        $templateLabelNode = Mage::app()->getConfig()->getNode(self::XML_PATH_TEMPLATE_EMAIL . $code . '/label');
                        if ($templateLabelNode) {
                            $templateName = Mage::helper('adminhtml')->__((string)$templateLabelNode);
                            $templateName = Mage::helper('adminhtml')->__('%s (Default Template from Locale)', $templateName);
                        }
                        array_unshift(
                            $options,
                            array(
                                'value'=> str_replace('/', '_', $code),
                                'label' => $templateName
                                )
                            );
                    }
                }
            }
        }

        return $options;
    }

}

Then in your custom module, you can use as in the following example in your config.xml:

<global>
    <template>
            <email>
                <design_email_header_custom_black translate="label" module="custom_module">
                    <label>Email - Header (CUSTOM BLACK)</label>
                    <file>html/header-custom-black.html</file>
                    <type>text</type>
                </design_email_header_custom_black>
                <design_email_header_custom_white translate="label" module="custom_module">
                    <label>Email - Header (CUSTOM WHITE)</label>
                    <file>html/header-custom-white.html</file>
                    <type>text</type>
                </design_email_header_custom_white>
                <design_email_footer_custom_black translate="label" module="custom_module">
                    <label>Email - Footer (CUSTOM BLACK)</label>
                    <file>html/footer-custom-black.html</file>
                    <type>text</type>
                </design_email_footer_custom_black>
                <design_email_footer_custom_white translate="label" module="custom_module">
                    <label>Email - Footer (CUSTOM WHITE)</label>
                    <file>html/footer-custom-white.html</file>
                    <type>text</type>
                </design_email_footer_custom_white>
            </email>
        </template>
</global>

So you have these options to select from:

System > Configuration > Design > Transactional Email

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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