Mastering the expert level of the Liquid customization language

With the new customization language , you can integrate many customization elements.

Adding personalization variables to emails helps make your messages more relevant and tailored to the needs of each of your customers, which greatly improves their engagement. This enriches the customer experience by making them feel recognized and valued, while strengthening their loyalty to your brand.

In this article, we will detail different use cases around the variables that you can integrate:

  • Control product display

  • Integrate variables

  • Format a variable

  • Integrate calculations

  • Add one or more conditions

Visit this article for more details on the new variables.

Checking product display

You can use conditions to control the display of products. Below is an example of a loop with a condition that only displays products priced above 50:

{% for product in products %} {% if product.price > 50 %} {{ product.title }} <!-- Ajoutez d'autres propriétés du produit ici --> {% endif %} {% endfor %}

In this example, the condition {% if product.price > 50 %} checks whether the product price is greater than 50. If the condition is met, the product title (and potentially other properties) will be displayed. You can also add other conditions using logical operators like and, or, ==, !=, etc., based on your specific needs.

Be sure to tailor the condition to match the criteria you want to use for displaying products.

Inserting variables

This section outlines best practices for using variables in your email designs.

  • Make sure to include the full variable name and its scope, as shown: {{ contact.firstname }}

---

For example:

  • In your email design, you would write: Hello {{ contact.firstname }}

  • In the email received by your contact, it will display: Hello Deborah

Formatting variables

To ensure consistent formatting for variables in your emails, you have the option to apply formatting rules.

For example:

  • You write this in your email design: Hello {{ contact.firstname | downcase }}

  • And the following will be displayed in the email received by your contact: Hello Deborah

Syntax

Output

{{ "Variable" | downcase }}

variable

{{ "variable" | upcase }}

VARIABLE

{{ "variable" | capitalize }}

Variable

{{ 1 | pluralize: 'item', 'items' }}

{{ 4 | pluralize: 'item', 'items' }}

another example: {{ orderline.quantity | pluralize: 'item', 'items' }}

item

items

Incorporating calculations

You can incorporate calculations into variables to display a numerical result as part of your email design personalization.

For example:

Definition

Syntax

Output

Addition

{{ 250 | plus: 10 }}

260

Subtraction

{{ 250 | minus: 10 }}

240

Multiplication

{{ 250 | times: 10 }}

2500

Division

{{ 250 | divided_by: 10 }}

25

Adding one or more conditions

Basic syntax

For example, you can check if a contact's language is set to English as follows:

{% if contact.language == 'EN' %}
Hello there
{% endif %}

You can add a fallback solution if the condition is not met using the else function:

{% if contact.language == 'EN' %}
Hello
{% else %}
Hello
{% endif %}
-

Syntax with multiple conditions

You can combine conditions as follows:

{% if contact.language == 'EN' %}
Hello
{% elsif contact.language == 'FR' %}
Bonjour
{% else %}
Hello
{% endif %}

-

Operators

==

equal

!=

not equal

>

bigger than

<

less than

>=

bigger or equal

<=

less or equal

or

this or that

and

must be this and that

contains

includes the substring if used on a string, or element if used on an array