After July 2021, the 2.3.x release line will no longer receive quality updates, or user guide updates. PHP 7.3 reaches end of support in December 2021 and Adobe Commerce 2.3.x reaches end of support in September 2022. We strongly recommend planning your upgrade now to Adobe Commerce 2.4.x to help maintain PCI compliance.

Adding Custom Variables

The information on this page is intended for Adobe Commerce 2.3 customers who are on an extended support contract. The Adobe Commerce Merchant Documentation for current releases is published on the Adobe Experience League.

To meet the specific needs of your business, you can create custom variables and insert them into pages, blocks and email templates. The list of allowed variables that appears when you click the Insert Variable button includes both predefined and custom variables. As shown in the following image, the list of available variables for a specific email template is determined by the data that is associated with the template. See the Variable Reference for a list of frequently-used email templates and their associated variables.

Only allowed predefined or custom variables can be used in email and newsletter templates.

Step 1: Create a custom variable

  1. On the Admin sidebar, go to System > Other Settings > Custom Variables.

  2. Click Add New Variable.

    Custom variables Custom Variables

  3. Enter an identifier for Variable Code, using all lowercase characters without spaces.

    If needed, you can use an underscore character or hyphen to represent a space. For example: my_custom_variable

  4. Enter a Variable Name, which is used for internal reference. For example: My Custom Variable

  5. To enter the value that is associated with the variable, do one of the following:

    • For Variable HTML Value, enter the variable value formatted with simple HTML tags. For example: <b>This formatted content appears in place of the variable.</b>
    • For Variable Plain Value, enter the variable value as plain text without formatting. For example: This unformatted content appears in place of the variable.

    If you need more room, drag the lower-right corner of the text box.

    New custom variable New Custom Variable

  6. When complete, click Save.

Step 2: Insert the custom variable

Example - insert a variable into a page

  1. Open the CMS page or block where the variable is to appear.

  2. Expand the Content section. Then, click Show / Hide Editor to work in HTML.

  3. Position the insertion point in the editor where you want the variable to appear and click Insert Variable.

  4. Select the option for the custom variable that you want to insert and click Insert Variable.

    New custom variable Select Custom Variable

    A command to insert the variable is enclosed in curly braces and added to the code at the cursor location. For example:

    customVar code=my_custom_variable

    New custom variable Custom Variable Code

  5. When complete, click Save.

Example - use Page Builder to insert a custom variable

  1. Open the page or block where the variable is to appear.

  2. Expand the Content section.

  3. In the left panel, click Elements and do one of the following:

    • Click in an existing text area where you want to insert the variable.

    • Drag a new Text object to the stage.

  4. At the far right of the editor toolbar, click () to insert a variable.

    Page Builder stage PageBuilder Stage and Panel

  5. In the list, select the custom variable that you want to insert and click Insert Variable.

    New custom variable Select Custom Variable

    The variable identifier appears as a placeholder in the editor.

    Page Builder stage Variable Placeholder

  6. When complete, click Save.