0

I'm trying to figure out how to load a different footer on the invoice emails.

The default footer will be loaded with:

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

This will load the template from /MY-THEME/Magento_Email/email/footer.html.

In my invoice template I would like to load:

{{template config_path="design/email/footer-invoice_template"}}

For this I have created a tempate: /MY-THEME/Magento_Email/email/footer-invoice.html.

But it isn't that easy.

What would be the best way to do this?

  • Alternatively you can put footer code directly in your invoice template. – Suresh Chikani May 1 '17 at 8:57
  • @SHPatel added my answer. – Minesh Patel May 1 '17 at 10:12
  • @Pierre check and let me know your result – Minesh Patel May 1 '17 at 10:13
  • @MineshPatel, Your answer makes sense. I will try it coming week. – Pierre May 2 '17 at 13:12
0

Email Template in magento work based on 2 values.

your template must be there in xml file OR in database.

For the first approach, You need to define and create your own email template for this in your custom module .for example etc/email_templates.xml from Module module-email

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="design_email_header_template" label="Header" file="header.html" type="html" module="Magento_Email" area="frontend"/>
    <template id="design_email_footer_template" label="Footer" file="footer.html" type="html" module="Magento_Email" area="frontend"/>
</config>

and template under module-email/view/frontend/email

OR

i have checked by dirty trick

Create new template from admin panel and grab value of id (increment id)

after that inserted entry in core_config_data

INSERT INTO `core_config_data` (`config_id`, `scope`, `scope_id`, `path`, `value`) VALUES (NULL, 'default', '0', 'design/email/footer-invoice_template', 'increment id');

in above case i have added increment id as 2 which is template id from DB which i have created

now you can place your template in any email

{{template config_path="design/email/footer-invoice_template"}}

it should work.

| improve this answer | |
0

First create your template under your custom module

app/code/Vendor/MyModule/view/frontend/email/footer_invoice_template.html

Second to load the template from configuration

app/code/Vendor/MyModule/etc/email_templates.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="footer_invoice_template" label="Footer" file="footer_invoice_template.html" type="html" module="Vendor_MyModule" area="frontend"/>
 </config>

third to use that footer invoice template in our templates with one single line add this line of code under

app/code/Vendor/MyModule/etc/config.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <design>
        <footer_invoice>
            <email>                    
                <template>footer_invoice_template</template>
            </email>
         </footer_invoice>
      </design>
    </config>

suppose if you want load this template into another template,just

{{template config_path="design/email/footer_invoice_template"}}
| improve this answer | |

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.