liquid - Multiple if condition not working on shopify liqued file
How are you. I use this code bellow for multiple if condition in shopify liqued file. but it's not working. Please anyone help where I mistake here.
{%- if product_collection == "Organic and Natural Products" and product_collection == "Dried Foods" -%} CONTENT HERE A {%- else -%} CONTENT HERE B {%- endif -%}
Answer
Solution:
The simple explanation is your logic is wrong. A quick example of what I mean:
if A is 3 AND A is 5 do something
Do you see the problem here? A can NEVER be two things at once. Instead, you probably want the or condition. That way, you get choices.
if A is 3 OR A is 5 do something
Then, your logic will display specific content when either condition for A is true. Otherwise you get the content when neither is true.
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.