Ad

Simple Liquid Markup For Shopify Not Working ...?

- 1 answer

I made this simple markup on a Shopify product-template.liquid section. It's not returning the second image though on different products outside of the ones specified.

{% if product.handle == "e" or "f" %}

{{ '3.png' | asset_url | img_tag }}

{% else %}

{{ '4.png' | asset_url | img_tag }}

{% endif %}

This seems pretty straight forward according to Shopify's documentation. However I can't get 4.png to come up on the other products in the store.

This seems like a really basic problem, but it's doing me in! What am I missing?

Ad

Answer

You can't chain conditional statements in liquid you need to redefine the comparison.

{% if product.handle == "e" or product.handle == "f" %}
  {{ '3.png' | asset_url | img_tag }}
{% else %}
  {{ '4.png' | asset_url | img_tag }}
{% endif %}
Ad
source: stackoverflow.com
Ad