I am using the edit HTML module in an email (not an email template) and trying to get the following bit of code to work:
{% if deal.deal_currency_code == ‘USD’ %}<p>usd text</p>{% else %}<p>non-usd text</p>{% endif %}
I am previewing it with the currency code property above it so that I can compare, but it only shows the else text.
The issue is not letter case. What am I missing here?
I also ran a print test using this and it came back false, even though the test deal is definitely USD.
{% if deal.deal_currency_code == "USD" %}<p>usd text</p>{% else %}
<p>non-usd text {{ deal.deal_currency_code == "USD" }}</p>{% endif %}
Hey @Thompson_DHARMA
Check the type of the value using the type function:
{{ type(deal.deal_currency_codedeal.deal_currency_code) }}
If it’s not “str” try converting it using the string filter first.
best
Thanks Kevin! With your advice I did use the string filter but it’s still not working, unfortunately.
We’re tried all sorts:
{% if personalization_token('deal.deal_currency_code') == 'USD' %}
<p>usd text</p>
{% else %}
<p>non-usd text</p>
{% endif %}
{% set currency_code = personalization_token('deal.deal_currency_code') | string %}
{% if currency_code == 'USD' %}
<p>usd text</p>
{% else %}
<p>non-usd text</p>
{% endif %}
{% set currency_code = deal.deal_currency_code | string %}
{% if currency_code == "USD" %}
<p>usd text</p>
{% else %}
<p>non-usd text</p>
{% endif %}
I have solved this myself. I created a Module in Design Manager and entered this code.
{% set currency_code = deal.deal_currency_code | string %}
{% if currency_code == "USD" %}
<p>usd text</p>
{% else %}
<p>non-usd text</p>
{% endif %}