To find the 'Condition' code block, select an element and scroll all the way to the bottom in the right hand navigation.
Using the Condition section of an element allows you to show / hide certain elements based on the value of a field or variable. As with the Setup block (guide here), the Condition can only be used in the element where the logic is set, or within its child elements.
Customer object fields can be referenced anywhere in Conditions.
Data stored in variables can be referenced as long as:
- The query is stored in the Variables section, or;
- The query is stored in the same element as the Condition, or;
- The query is stored in a parent element of the Condition.
This element will only show if the user’s first_name field is not blank:
This section will show if ‘b_data’ is not empty:
This section will show if the ‘name’ of the first record returned in b_data contains ‘Denim’:
Note: 'and’ or ‘or’ clauses can be used to check for more than 1 condition.
This element will only show if the user’s first_name and last_name are not blank:
- Liquid is “an open source template language created by Shopify”
- “Open source”: Engineers can make changes to it and adapt it for their own needs -- we did this
- “Template language”: A nice way to put data on an email/page
- Sources of public documentation:
- Shopify’s: https://help.shopify.com/en/themes/liquid
- Ours: https://support.optimizely.com/hc/en-us/articles/4407775274253-Personalize-with-optional-content
- Ours: https://support.optimizely.com/hc/en-us/articles/4407775333261-Advanced-Liquid-capabilities-in-ODP
- Shopify also has a Github repo for local testing: https://shopify.github.io/liquid/