How to add variables to custom notification emails
Help Desk notifications support standard Magento email template variables, such as {{var logo_alt}}
, and function calls, like {{var store.getFrontendName()}}
. It also provides a set of its own variables:
{{var customer}}
- allows access to customer properties{{var ticket}}
- allows access to ticket properties, including custom fields (see below){{var department}}
- allows access to department properties
The most useful properties are:
-
{{var customer.getName()}}
- name of the current customer -
{{var customer.getEmail()}}
- email of the current customer -
{{var department.getName()}}
- name of the department to which the current ticket was assigned -
{{var department.getSenderEmail()}}
- sender email, used as the "From" field in notifications -
{{var ticket.getCode()}}
- code of the current ticket, e.g., YVB-459-53185 -
{{var ticket.getName()}}
- subject of the current ticket -
{{var ticket.getCustomerEmail()}}
- email of the current customer -
{{var ticket.getCustomerName()}}
- full name of the current customer -
{{var ticket.getLastReplyName()}}
- full name of the customer or staff member who last replied to the current ticket -
{{var ticket.getFrontendLastReplyName()}}
- name of the author of the last reply as it is displayed on the frontend (depending on the option Store -> Configuration -> Help Desk -> General settings -> Sign staff replies) -
{{var ticket.getChannel()}}
- name of the channel that created the ticket, e.g., 'email', 'backend', or 'feedback_tab' -
{{var ticket.getExternalUrl()}}
- frontend URL of the current ticket -
{{var ticket.getBackendUrl()}}
- backend URL of the current ticket (this variable works correctly if the Stores -> Configuration -> Advanced -> Admin -> Security -> Add secret key to URLs option is disabled) -
{{var ticket.getLastMessagePlainText()}}
- contents of the last message posted -
{{var ticket.getUserName()}}
- full name of the current ticket owner -
{{var ticket.getOrder()}}
- returns the order object to which the current ticket is bound, providing access to all order properties (see the example below; note that these properties can be used within the{{depend}}
tag)
Assume that you have to get the order number, to which the current ticket is bound. This requires the following code:
{{depend ticket.getOrder()}}
{{var ticket.getOrder().getIncrementId()}}
{{/depend}}
Additionally, custom fields can be used as email variables. Each custom field has a code. Assume we have created a field with the code custom_email
. The corresponding email variable would be:
{{var ticket.getCustomEmail()}}
- Email of the current customer.