Using OR in if statements

Can I use OR in an if statement? for example {if: a == "Yes" OR b == "Yes" and c == "No"} then say this.

Hey there @Santa_Laren Hope you are having a great day.

To answer your question, yes, you can include an OR statement in your snippets. Here is an example of how it looks in Text Blaze.

Select an option{formmenu: default=1; 2; 3; 4;5; name=Options; multiple=no}

{if: options==1 OR options==2}You selected 1 or 2{elseif: options==3 OR options==4}You selected 3 or 4{else}You selected 5{endif}

Example with AND it shows if your store is closed when you select the option 1

Is your store closed? {formtoggle: name=Closed; default=yes}

{if: closed == yes AND options==1}Your store is closed and you selected 1{elseif: closed==no AND options==1}Your store is open and you selected 1{else}You selected something else{endif}

Hope this helps :hugs: I am happy to help if anything else.

2 Likes

Thank you for your reply Diego. That helps.

2 Likes

Thanks @Diego_Suancha for the great example.

@Santa_Laren - here's another option you might want to explore:

option1: {formmenu: name=option1; yes; no}
option2: {formmenu: name=option2; yes; no}
option3: {formmenu: name=option3; yes; no}

{if: (option1=="yes" or option2=="yes") and option3=="yes"}Option 1 or 2 is "yes" AND option 3 is also "yes"{elseif: option3=="no"}Option 3 is "no". We don't care what options 1 and 2 are.{else}This is what shows up if none of the other conditions are met.{endif}

1 Like

Very helpful, thank you Cedric!

1 Like

You're most welcome @Santa_Laren,

If you're interested, I have a special thread where members can throw any snippet at me and I try to find ways to improve it.

It's a lot of fun, and hopefully you get to walk away with a snippet that saves you even more time :slight_smile:

Here it is: