Magento – Add email variable to all transactional emails

custom-variablemagento2transactional-mailvariables

Is there any way to add one email variable to all transactional emails?

My idea is to create a custom variable, put some code in it and display it in all transactional emails.

Best Answer

Assume you want to add custom variable in Email main content section but not in Email Header or Footer section.

To add a custom variable, please follow below admin path.

1) Login into admin.

2) go to SYSTEM -> Custom Variable (under "Other setting").

3) Click "Add New Variable" button.

4) Enter Variable Code****,Variable Name,Variable HTML Value [optional], Variable Plain Value[optional]

5) Click "Save" button.

To use the custom variable in all email template, you need to do the following steps :

Srep 1) Create Custom Emil Templates

Go to Admin -> Marketting-> Email Templates

click Add New Template

Select and load the template where you want to use the custom variables,

Enter Template Name : (something meaningful so you can easily identify your custom template)

on the Template Content, click where you like to insert the custom variable,

Click "Insert Variable"

Select the custom variable

Finally, save the template

step 2) Configure Magento to use your custom Email Template

You need to navigate to particular config area for which you want to change the email template. To change all email templates you need to update email template configuration for all areas.

For Example :

To change "New Order Confirmation Template", Go to STORES-> Configuration -> SALES -> Sales Email ->click "Order" tab to open it up and uncheck "Use System Value" for New Order Confirmation Template and select your custom email template-> click "Save Config"

You can see this link https://www.magestore.com/magento-2-tutorial/magento-2-add-variables-magento-2-templates/ for more info.

enter image description here enter image description here enter image description here

Related Topic