Use Lookup Table in Email Template
To use a lookup table in an email template, you can add the following liquid syntax to your HTML template or to an HTML element used in a drag-and-drop builder:
{% assign variable_name = "lookup-table-slug" | lookup: "item-name", "object-value" %}
{{variable_name.key_name}}Here,
variable_name is any name you can define
lookup-table-slug is the slug you have given when creating the lookup table
item-name is the name of the item you have created
object-value is the value you have given for the JSON item
key_name is the name of the key in the key-value pair defined under item-value
For example,
To render the local currency of a defined country, we can use the below syntax
variable_name here is defined as currency (any name that the user can define)
lookup-table-slug here is country-flags as defined when the lookup table was created
item-name is the country as created earlier and shown in the left pane
object-value is AD, which is the value defined in the JSON. Note that this can also be a variable
key_name is the local_currency, which is defined in the JSON
{% assign currency = "country-flags" | lookup: "country", "AD" %}
{{currency.local_currency}}When used in the email template builder in an HTML block, the above syntax will render the value of the local_currency as stored under the AD object under the country item in the lookup table country-flags
You can switch to the preview section to see the output value displayed dynamically in the email template. Below, it is showing EUR as the value fetched from the look-up table.
Last updated
Was this helpful?

