How to add variables to custom notification emails
Help Desk notifications also support standard Magento email template variables, such as {{var logo_alt}}
, and supports function calling, like {{var store.getFrontendName()}}
, and adds 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 usable properties are:
-
{{var customer.getName()}}
- name of current customer -
{{var customer.getEmail()}}
- email of current customer -
{{var department.getName()}}
- name of department to which current ticket was assigned -
{{var department.getSenderEmail()}}
- sender email, used as the fieldFrom
in notificators -
{{var ticket.getCode()}}
- code of current ticket, e. g. YVB-459-53185. -
{{var ticket.getName()}}
- subject of current ticket. -
{{var ticket.getCustomerEmail()}}
- email of current customer. -
{{var ticket.getCustomerName()}}
- full name of current customer. -
{{var ticket.getLastReplyName()}}
- full name of customer or staff member who last replied to the current ticket. -
{{var ticket.getFrontendLastReplyName()}}
- name of the author to the last reply as it is displayed at the frontend (depending from 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 current ticket. -
{{var ticket.getBackendUrl()}}
- backend URL of current ticket. The variable works correctly if the Stores -> Configuration -> Advanced -> Admin -> Security -> Add secret key to URLs option is disabled. -
{{var ticket.getLastMessagePlainText()}}
- contents of last message posted. -
{{var ticket.getUserName()}}
- full name of current ticket owner. -
{{var ticket.getOrder()}}
- returns order object to which current ticket was binded. It provides access to all order's properties (see example below, note that these properties can be used within{{depend}}
tag).
Assume that you have to get the order number, to which the current ticket is binded. This requires the following code:
{{depend ticket.getOrder()}}
{{var ticket.getOrder().getIncrementId()}}
{{/depend}}
Also, if there is a custom field, it can be used as an email variable. Each custom field has a code. Assume that we have created a field with the custom_email
code. Then the corresponding email variable is:
{{var ticket.getCustomEmail()}}
- Email of the current customer.