How to add variable in all Magento 2 templates

Here, we will explain to you how to add variable in all Magento2 templates in simple

What Exactly Variable is ?

Variable are part of information that can be build once and used in multiple places, such as email templates, blocks, and content pages.There are two types of variables: Predefined Variables & Custom Variables.

Magento 2 you can get the following default variables that can be added :

Magento2 templates

In Magento 2 templates, we include a variable which is an easy way to insert a pre-defined part of code to your CMS pages or Blocks. At this instant, we will establish you how to add variable in all Magento 2 templates.

Variables are piece of information that can build once and utilize in multiple places, such as Email templates, Blocks and content pages. There are two types of variable:

  • Predefined variable
  • Custom variable

Your store holds large number of a predefined variable that can be used to individualize communication.

In magento 2 you can discover a default variables but the list of default variable is limited. In addition, you can make your own custom variables.

Now we will learn how to add variable in all magento templates.

The following steps illustrate you how to create predefined variables:

Step 1: choose the template you want to include variables. It can be Email Templates or page templates.

For example: Go to marketing->communications->Email Templates. Then select a template you want to build a variable.

Step 2: select insert variables. Then select a variables that you want to create to that template.

Step 3: After completing, click save template.

The following steps illustrate you how to create custom variables:

Step 1: on the admin slide bar, tap system, then other setting ->custom variable .

Custom variable

after that select add new variable

Custom variable

Step 2: enter the custom variable information

  • In variable field, enter an identifier and exploit all lowercase character without space.
  • In variable name, type a variable name which is used as an internal reference
  • In HTML value text field, form any content that you insert using HTML values. This option allows you to format the value.
  • Type the variable value as simple text in a variable plain value,

After complete, click save

The below mentioned are some of the variable reference which assists you to add more custom variable in HTML.

Billing address: {{var formattedBillingAddress|raw}}
Email Order Note:  {{var order.getEmailCustomerNot1e()}}
Order ID: {{var order.increment_id}}
Order Item Grid:  {{layout handle=”sales_email_order_items”order=$order area=”frontend”}}
Payment Option:  {{var payment_html|raw}}
Shipping Address:  {{var formattedShippingAddress|raw}}
Shipping description: {{var order.getShippingDescription()}}

I hope the above mentioned information will be useful you to add variable in all magento templates.

Last Update: June 24, 2019  

February 2, 2018   1126   Nandini R    Marketing    
Total 1 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Reply

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

Facebook
Twitter
INSTAGRAM
LinkedIn