In the examples below, ESL is used to modify the html code.
price
Red font in the template, but if there is no strike price, the price should be displayed in black.
<font{% if product.price>=product.msrp %} style="color:black;"{% endif %}>{{ product.price|number_format(2, ',', '.') }} €</font>
link
The customer delivers the following link https://www.lifestyle.com/de-de/product.html → de-de should be exchanged with the country code at the contact (e.g. de-en). Replacing is not possible! Tracking parameters can also be attached.
{{ "https://www.lifestyle.com/{{ contact.16689}}/" ~ product.link|split('/')|last }}?utm_term={{product.item_id}}
title
customer delivers: brand - title → but only the title should be output
{{ product.title|split(' - ')|last }}
MSRP: is greater
If the MSRP is greater than the price, this should be the output, otherwise just use space characters.
{% if product.price<product.msrp %}{{ product.msrp|number_format(2, ',', '.') }} €{% else %} {% endif %}
{% if product.price<product.msrp %}${{product.msrp}}{% else %}{{ '' }}{% endif %}
{% if product.price<product.msrp %}{{product.msrp}} €{% else %}{{NULL}}{% endif %}
MSRP: missing strike price
Using this function we keep the space character for the missing strike price. The description and CTA do not move up the table.
{% if product.msrp != '' %} {{ product.msrp|number_format(2, ',', '.') }} €{% else %} </s> <br> {% endif %}
MSRP: two strike prices
Two different strike prices (c_price_competition
and c_price_instead
) are issued in different formats:
Full amount= x'xxx,- else x'xxx.xx
Zeros at the end are removed, then it is checked if the last character is a full stop .
or not. Values in this case have 4 digits after the decimal point.
{% if product.c_price_Konkurrenz<=product.c_price_instead and product.price<product.c_price_instead %}
Statt: CHF {% set trimPreis=product.c_price_instead|trim('0', 'right')%}
{% if trimPreis|last=='.' %} {{ product.c_price_instead|number_format(0, '.', "'") }}.-
{% else %} {{ product.c_price_instead|number_format(2, '.', "'") }} {% endif %}
{% elseif product.price<product.c_price_Konkurrenz %}
KKV: CHF {% set trimPreis=product.c_price_Konkurrenz| trim('0', 'right')%}
{% if trimPreis|last=='.' %} {{ product.c_price_Konkurrenz|number_format(0, '.', "'") }}.-
{% else %}{{ product.c_price_Konkurrenz|number_format(2, '.', "'") }} {% endif %}
{% else %} {% endif %}
ITEM ID
In case parent product starts with g/0
, it is cut off - then all leading 0.
ITEM ID: {%set item_ohne_g=product.item_id|trim('g/0', 'left') %} {{item_ohne_g|trim('0', 'left')}}
description
Formatting example: a different font size is used within the description, line break.
</br><font style="font-size: 11px;">Artikel-Nr.: {{product.item_id|trim('0', 'left')}}</font>
text link
Modifying an HTML link:
<a href="{{product.link}}" title="{{product.title}}">{{product.title}}</a>
Integer check
If integer type of condition. Please note if the value x.00 is stored in the Magento price field, this is recognized as an integer.
{% if product.price matches '/^\d+$/' %}
show/hide price
Show or hide a price element depending on product catalogue values.
Custom Variable to fill the price e-editable with the corresponding value from the product catalogue:
1{{"{% if show_priceB == true %}" ~ product.price|number_format(2, ',', '.') ~ "€ {% endif %}"}}
1{% if product.msrp is empty %}
2 {{'{% set show_priceB = false %}'}}
3{% else %}
4 {{'{% set show_priceB = true %}'}}
5{% endif %}
local specific
Show elements from other local or from a specific local.
price → price_default_store_view (local: default_store_view)
c_size → c_size_de (local: de)
The available zone sonderpreis for default zone, c_sonderpreis exists just for the default zone, but must be added via RAW, while standard field (like price) in each zone can be add as usual.
{{ rawProduct['price.default_store_view'] }} / {{ rawProduct['customs.size_de'] }}
{% if rawProduct['available.sonderpreis']==true %}{{rawProduct['customs.sonderpreis']}}
price/ml
Using if
query you can also decide whether you want to have price per 1 l or price per piece.
{{ product.price|format_currency('EUR', locale='de') }} / {{ product.c_size }}
{%set mengenpreis= product.price*100/product.c_size|split(' ')|first%}
{{ mengenpreis|number_format (2,',','.') }} € / 100 {{ product.c_size|split(' ')|last }}
Customer stopper: discount
Using this function the difference between the price and msrp is calculated and shown in the red top bar together with the discount in percent. If no discount is given (Product catalogue difference between price and MSRP), then red bar is not shown. In this case, the extra space of the red bar needs to be separately disabled form the optional contents.
Please be aware that this is one of the first ESL approaches with the new VCE Editor therefore parts of the Blocktemplate ESL were integrated here in the ESL to not show the red bar that is normally part of the Template.
{% set percent = 100-(product.price*100/product.msrp) %}
{% if percent == 0 %}
{% set percent = '' %}
{{percent}}
{% else %}
'<table cellpadding="0" cellspacing="0" bgcolor="{variables.badgebg}" class="tbadge"><tr><td align="center" style="padding:6px 10px;" class="lh la2b"><font class="ff fs10 fc2 fwb xsmall">{{percent}}</font></td></tr></table>'
{% endif %}
Multilanguage vs. Product search add-on
To use the product search add-on automatically with multilanguage campaigns you need to:
-
Add a blanc html entity to the template. This e-editiable element will be replaced with the product item information.
<tr style="display:none;"> <td e-editable="pD_1"></td> </tr>
-
Set the configuration in the product add-on settings:
-
Create a custom variabl VCE Product Search Addon v2 | Step 2: Configure Custom Variables
-
add the following ESL Code to your custom variable:
{{ ("{% set productData = "~ rawProduct|json_encode ~" %}")|raw }}
-
-
Once you selected a product via product search add-on you’ll be able to use all product data fields with ESL snippets like:
{{productData["price.de_DE"]}}
1{% if contact.<<IETF Contact Field ID>> = 'de_DE' %}
2{{productData["price.de_DE"]}}
3etc.
4{% endif %}