Liquid, JavaScript, themes, sales channels
I'm using product type and tags to show relevant shipping images on my product pages.
My concern is that filtering logic using product.type or tags does not seem to be working.
I'm seeing the image on products that don't have 'freeshipping' tag and the product.price > 225 definitely isn't triggering.
The logic seems straight forward but this product has no freeshipping tag and yet still shows an image
I added an extra {% else %} at the end just in case but no luck.
{% if product.type == 'retro arcade games console' and product.tags contains 'freeshipping' and product.price > 225 %}
<img src="https://cdn.shopify.com/s/files/1/0494/6935/8246/files/free-shipping-product-under-price.gif?v=16189..." alt="" class="free-shipping_img">
{% else if product.type == 'retro arcade games console' and product.tags contains 'freeshipping' %}
<img src="https://cdn.shopify.com/s/files/1/0494/6935/8246/files/free-shipping-over-225.gif?v=1620036880" alt="" class="free-shipping__img">
{% else %}
{% endif %}
Would appreciate your input as to where I've gone wrong here.
Thanks
Solved! Go to the solution
This is an accepted solution.
Can you first fix your else if line?
It is not:
else if
but rather
elsif
See reference:
https://shopify.dev/docs/themes/liquid/reference/tags/control-flow-tags
This is an accepted solution.
Can you first fix your else if line?
It is not:
else if
but rather
elsif
See reference:
https://shopify.dev/docs/themes/liquid/reference/tags/control-flow-tags
Thanks Jason,
Read through that a few times but seems I somehow mixed up the else and elseif.
That's stopped it showing on some products 🙂
The logic is still failing as showing the first image even if I move price upto 260 which should trigger the elsif here https://electroarcade.com.au/collections/arcade-machines/products/split-retro-arcade-leading-game-co...
{% if product.type == 'retro arcade games console' and product.tags contains 'freeshipping' and product.price > 260 %}
<img src="https://cdn.shopify.com/s/files/1/0494/6935/8246/files/free-shipping-product-under-price.gif?v=16189..." alt="" class="free-shipping_img">
{% elsif product.type == 'retro arcade games console' and product.tags contains 'freeshipping' %}
<img src="https://cdn.shopify.com/s/files/1/0494/6935/8246/files/free-shipping-over-225.gif?v=1620036880" alt="" class="free-shipping__img">
{% else %}
{% endif %}
more tweaking and sorted it all out.
🙂
Glad you got it sorted. That elsif is an easy trap to fall into. I've done it plenty of times. You'd think i'd have it down after all these years but still the brain sometimes defaults to "else if".
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024