Solved

Having issues with IF ELSE logic statements in email

  • 22 February 2023
  • 2 replies
  • 152 views

Badge +1

Hi,

I am having issues understanding IF/ELSE statements for email.

I went through an article and a few questions on here about syntax and IF/ELSE statements. They used the person|lookup variable.

Example:

{% if person|lookup:'Interested in Dogs?' and not person|lookup:'Interested in Cats?' %}  

 Like dogs? Check out some great toys for your canine.

{% elif person|lookup:'Interested in Cats?' and not person|lookup:'Interested in Dogs?' %}  

 Like cats? Check out some great toys for your feline.

{% else %}

Check out some great toys for your pet!

{% endif %}


My question: Would it be possible to use IF/ELSE statements to pull IF a user has a listed item in their cart pull the description or list x,y,z benefits, or If they have a different item to list the benefits of the other item? |

What would the best example of using IF/ELSE statements like this (using to show the benefits of a product a user has left at checkout) be or is there a youtube that would show other ways to use IF/ELSE statements?


Thanks,

icon

Best answer by retention 23 February 2023, 01:31

View original

2 replies

Userlevel 7
Badge +57

Hi @B Mo, welcome to the community!

Perhaps you were looking at one of my articles, your code looks a bit familiar. :)

My article has a few other hypothetical examples, but generally speaking you can use the IF / ELSE to Show/Hide Blocks or even whole sections of Text (or HTML) whenever you want to condtional adjust the template based on a Custom Property or an Event Variable.

For your specific example, you can certainly have an IF/ELSE or a Show/Hide of certain blocks of benefits based on what it is in the cart.  It might be tedious to do this if you have a lot of different items in the store, so I recommend using the products’ category/collection or tags - that way you can organize your products accordingly and map these various IF/ELSE or Show/Hide blocks to groups of items. 

Hope this helps!

Badge +1

Thanks!

Again you’ve been super helpful!

Reply