03-28-2024 04:49 AM
I am trying to create a piece of dynamic content that shows for multiple countries.
I have created this code which worked a few weeks ago, but now isn't working:
{% if {{${country}}} == 'ID' and 'AE' and 'TR' and 'EG' and 'SA' and 'PK' and 'BD' and 'MY' and 'NG' %}
I have tried with or and that doesn't work either!
Any help would be massively appreciated, thank you.
03-28-2024 11:07 AM
Try including the country attribute in each statement, like:
{% if {{${country}}} == 'ID' and {{${country}}} == 'AE' and {{${country}}} == 'TR' ....
04-01-2024 07:36 PM - edited 04-01-2024 07:38 PM
Hi @roebuckl
@chris is spot on, as you need to let Braze know you want to check the attribute for each term e.g. does country = AE and does country == TR and so on.
Reading the liquid however, you might need to test this but I feel like you will need to use OR for your use case.
{% if {{${country}}} == 'ID' and {{${country}}} == 'AE' and {{${country}}} == 'TR' ....
This liquid currently reads as 'for user X, does their country attribute equal 'ID' and 'AE' and 'TR'... and it cannot be all three at once.
Happy to be corrected but I feel you might need this if you are wanting to select different countries:
{% if {{${country}}} == 'ID' or {{${country}}} == 'AE' or {{${country}}} == 'TR' ....
'for user X, does their country attribute equal 'ID' or 'AE' or 'TR'...
If you are wanting the content to go to bunch of different countries that you select with liquid
04-02-2024 02:28 AM
Thanks both! We got it sorted with this:
{% if {{${country}}} == 'ID' or {{${country}}} == 'AE' or {{${country}}} == 'TR' or {{${country}}} == 'EG' or {{${country}}} == 'SA' or {{${country}}} == 'PK' or {{${country}}} == 'BD' or {{${country}}} == 'MY' or {{${country}}} == 'NG' %}
04-08-2024 07:54 AM
Hey @roebuckl , @DavidO @chris
I've started using Case/When more and more for things like this. I think it's cleaner than if/elsif. Eg:
{% assign country = {{${country}}} %}
{% case country %}
{% when "GB" %}
Copy for GB
{% when "FR", "AR" %}
Copy for FR or AE
{% when "TR" %}
Copy for TR
{% else %}
Copy for everyone else
{% endcase %}