Hi friends,

Have you ever want to add more information into any templates in your site but worry about how to deal with HTML? Some store owners have told us that they don’t know anything about code and can you guest, Magento Provider knew it too. In Magento 2 templates ,  we have variables which is an easy way to add pre-defined pieces of code to your CMS pages or blocks. Besides, It can do better than that. So today, we will introduce to you how to add variables for all magento templates in easy.

So what exactly variables is?

Variables are pieces of information that can be created once and used in multiple places, such as email templates, blocks, and content pages. There are two kinds of variables: Predefined Variables & Custom Variables. Your store includes a large number of
predefined variables that can be used to personalize communications. In Magento 2.0 you can find the following default variables that can be added:

magento 2 templates

But the list of default variables is limited. In addition, you can create your own custom variables.

Now, we will learn how to add variables for all magento templates?

Firstly, we will learn how to add  Predefined Variables by doing the following:

Step 1:  Choose the templates you want to add variables. It can be email template or page template. Example: To add variables to email templates. Firstly, navigate to Marketing>Communications>Email Templates. Then choose want template you want to add variables (or create new templates).

Step 2: Tap Insert Variables. Then choose variables you want to add to that template.

add variables for all magento 2 templates

Step 3:  When complete, tap Save Template.

Besides, If you know a little basic HTML, you can create custom variables and use a markup tag to incorporate them into pages, blocks, banners, and email templates.  To create a custom variable, you need to do the following:

Step 1:  On the Admin sidebar, tap System. Then under Other Settings, choose Custom Variables.

add variables for all magento 2 templates

After that, tap Add New Variable.
magento 2 templatesStep 2: Enter the custom variables information.

magento 2 templates

  • In the Variable Code field, Enter an identifier and use all lowercase characters, without spaces.
  • Enter a Variable Name, whichu is used for internal reference.
  • In the Variable HTML Value text field, enter any content you want to include, using basic HTML tags. This option allows you to format the value.
  • In the Variable Plain Value field, enter the variable value as plain text.

Step 3:  When complete, tap Save.

And we have some gifts for you. Here is Variable Reference for you to add more custom variables (in HTML):

Billing Address: {{var formattedBillingAddress|raw}}
Email Order Note: {{var order.getEmailCustomerNote()}}
Order ID: {{var order.increment_id}}
Order Items Grid: {{layout handle=”sales_email_order_items”order=$order area=”frontend”}}
Payment Details: {{var payment_html|raw}}
Shipping Address: {{var formattedShippingAddress|raw}}
Shipping Description: {{var order.getShippingDescription()}}

Above is all of guideline about Variables in Magento 2. Hope that it will help you. If you have any concern, feel free to comment below, I will reply soon.

Professional Invoice Save You from Refund Requirements

Explore Magestore PDF Invoice for Magento 2  >>>HERE<<<

magento 2 templates


Ready to foster your knowledge

with MAGENTO 2 BASIC GUIDE

Is your site still a mess and Magento extensions are not enough to save your site? Save your site with Magento Web Development Services now

magento services


[17]. How to set up RSS Feeds in Magento 2?
[19]. Magento 2: Introduction about Markup Tags.

Leave a Reply

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