Skip to main content

Use variables in transactional email templates in Magento Open Source and Adobe Commerce

Learn what variables you can use in your new account, order, shipping, invoice, and stock transactional email templates.

Gareth Burroughes avatar
Written by Gareth Burroughes
Updated over 2 weeks ago

This reference document lists all the variables that are available for Adobe Commerce transactional email campaigns. You can also use any Adobe Commerce variables in the subject line of your transactional email template.

When building your transactional email templates, the variables must be inserted to merge the customer, order, and shipping information.


Before you start

Things you need to know:

  • Using Dotdigital data fields in your Adobe Commerce transactional email template causes the send to fail because the sends are triggered directly from Adobe Commerce.

  • Since Adobe Commerce is customisable, each environment can interpret the variables differently. It's strongly recommended to reach out to your agency for a detailed list of variables that you can use.

  • There's no guarantee the variables in this article will work in your unique environment. Support is limited and suggestions can only be provided to you. It's not possible to tell you which ones you should use, and because of this, your agency is the best resource to help answer these types of questions.


New account variables

Variable name

Variable

Customer name

{{var customer.name}}

Store name

{{config path="general/store_information/name"}}

Customer account URL

{{var this.getUrl($store, 'customer/account/')}}

Forgot account password URL

{{this.getUrl($store,'customer/account/createPassword/',[_query:[id:$customer.id,token:$customer.rp_token],_nosid:1])}}

Customer email

{{var customer.email}}


New order confirmation variables

Variable name

Variable

Customer name

{{var order_data.customer_name}}

Store name

{{config path="general/store_information/name"}}

Customer account URL

{{var this.getUrl($store, 'customer/account/')}}

Order ID

{{var order.increment_id}}

Order created/placed at

{{var order.getCreatedAtFormatted(2)}}

Order status

{{var order_data.frontend_status_label}}

If order notes

{{depend order.getEmailCustomerNote()}} {{/depend}}

Order notes

{{var order.getEmailCustomerNote()|escape|nl2br}}

Billing address

{{var formattedBillingAddress|raw}}

Shipping address

{{var formattedShippingAddress|raw}}

Payment method

{{var payment_html|raw}}

Shipping method

{{var order.getShippingDescription()}}

Order items

{{layout handle="sales_email_order_items" order=$order area="frontend"}}

New shipment variables

Variable name

Variable

Customer name

{{var order_data.customer_name}}

Store name

{{config path="general/store_information/name"}}

Customer account URL

{{var this.getUrl($store, 'customer/account/')}}

Order ID

{{var order.increment_id}}

Order status

{{var order_data.frontend_status_label}}

Shipment ID

{{var shipment.increment_id}}

Shipment comment

{{var comment|escape|nl2br}}

Shipping tracking details

{{block class='Magento\Framework\View\Element\Template' area='frontend' template='Magento_Sales::email/shipment/track.phtml' shipment=$shipment order=$order}}

Billing address

{{var formattedBillingAddress|raw}}

Shipping address

{{var formattedShippingAddress|raw}}

Payment method

{{var payment_html|raw}}

Shipping method

{{var order.getShippingDescription()}}

Shipment items layout

{{layout handle="sales_email_order_shipment_items" shipment=$shipment order=$order}}


New invoice variables

Variable name

Variable

Customer name

{{var order_data.customer_name}}

Store name

{{config path="general/store_information/name"}}

Customer account URL

{{var this.getUrl($store, 'customer/account/')}}

Order ID

{{var order.increment_id}}

Order status

{{var order_data.frontend_status_label}}

Invoice ID

{{var invoice.increment_id}}

Invoice comments

{{var comment|escape|nl2br}}

Billing address

{{var formattedBillingAddress|raw}}

Shipping address

{{var formattedShippingAddress|raw}}

Payment method

{{var payment_html|raw}}

Shipping method

{{var order.getShippingDescription()}}

Order invoice items layout

{{layout area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order}}


Product stock alert variables

Variable name

Variable

Customer name

{{var customerName}}

Store name

{{var alertGrid|raw}}


Newsletter subscription confirmation variables

Variable name

Variable

Default newsletter subscription confirmation

{{var subscriber_data.confirmation_link}}


How variables and template styling work together

Variables allow you to dynamically insert personalized content into your email templates, while CSS ensures these templates maintain a consistent and branded look.

Insert dynamic content:

  • Variables such as {{var customer.name}} and {{config path="general/store_information/name"}} insert dynamic content into your email templates. This ensures that each email is tailored to the recipient.

Style with CSS:

  • When customising the design of your email templates, you can incorporate these variables within the HTML structure. For example, you can style the customer name using CSS:

<p style="font-size: 16px; color: #333;">Hello, {{var customer.name}}</p>

Maintain consistency:

  • By using the default CSS provided in Magento's theme, you can ensure that your customized templates maintain a consistent look and feel with the default Magento emails. This involves using the same CSS classes and styles while inserting the variables where needed.


Style and customise templates

You can add basic CSS to your templates to ensure your transactional emails match the default formatting and your brand's design. This section provides an overview of the steps to customize your email templates.

Style template

As a merchant, you may want to send a branded Dotdigital campaign for new order confirmations that resembles the default Magento email structure but with your company’s design.

To do this:

  1. Create a triggered email campaign.
    Learn more in Create a triggered email campaign.

  2. Copy the Magento default CSS template.

  3. Paste the CSS into the source code of your campaign.
    Learn more in Add CSS to your email templates.

  4. Find the placeholder data in your email template.
    For example:
    <div class="order-items">[Placeholder for order items]</div>

  5. Replace the placeholder data with Magento variable tags wrapped in {% raw %} tags.
    For example:
    {% raw %}{{layout handle="sales_email_order_items" order_id=$order_id area="frontend"}}{% endraw %}
    This step ensures the email content is dynamically generated based on Magento data.

  6. Save and test your campaign.

The default CSS template for sales emails is specific to the Magento_Sales module. For other emails, you can find the corresponding CSS in the relevant module.

See also:

Did this answer your question?