The eval:expr scope is the most powerful placeholder: it evaluates an expression and prints the result.
It allows you to perform calculations, concatenations, formatting, and conditional logic directly within the communication without modifying the template code; the code can simply be copied into a text element (HTML view).
| Expression | Result |
|---|---|
[eval:expr value="1 + 1"] | 2 |
<meta mn:temp mn:name="t1" mn:type="int" mn:value="1"> <meta mn:temp mn:name="t2" mn:type="int" mn:value="2">
| 3 |
[eval:expr value="'valore ' + 'stringa ' + 'concatenata'"] | concatenated string value |
[eval:expr value="temp.t1 + '_' + temp.t2"] | 1_2 |
[eval:expr value=temp.item.title {Titolo prodotto} left=10] | Titolo pro |
[eval:expr value="fn.if(temp.item.promo, temp.item.currentprice * fn.strtonumber(temp.item.discount, ','), temp.item.currentprice)"] | 8,62 |
To use constant strings inside the value="" you can use the following approaches:
- single escape + double quotes →
value="\"stringa\" + \"concatenata\"" double escape + single quote →
value="'che bell\\'albero'"
Conditional text based on a contact field
A contact must receive a coupon with a variable value that can be either points or currency. If the TIPO_COUPON field contains “Euro”, the output will be “€ for you!”, otherwise “points for you!”.
Insert the following code into a text element:
C'è un buono da [contact:VALORE_COUPON]
[eval:expr value="fn.if(contact.values.TIPO_COUPON eq 'Euro', '€', ' Punti')"] per te!
Approfittane entro il 2 luglio! Vai su nella sezione Buoni di App o sito web.Discount percentage
A Contact Extension based on the Shopify product catalog has been created and populated in the account. The following expression prints the discount percentage for each product:
[eval:expr value="fn.round(((temp.item.compareatprice - temp.item.price) /
temp.item.compareatprice) * 100)" designvalue='20']%Coupon expiration date: today +15 days
[eval:expr value="fn.dateadd(fn.now(), +15, 'day')" ]Print the current date and time using a specific pattern
[eval:expr value="fn.now()" pattern=YYYY-MM-dd'T'HH:mm:ss]