Goal: add logic-driven icon badges (e.g., Soil Association logo for “Organic”) to Shopify product cards, with conditions to hide when sold out and show when on sale.
Current implementation: card-product.liquid renders a Sold out or On sale badge using Liquid:
Sold out when card_product.available == false.
On sale when card_product.compare_at_price > card_product.price and available.
Tag-based badges: additional spans render text badges when product tags include:
“Organic”
“Gluten free”
“Alt Meat”
These are currently text-only and not conditioned to hide on sold-out products.
Key mechanics: Liquid checks for product availability (card_product.available), sale state (compare_at_price > price), and tag presence (card_product.tags contains ‘…’). Icons/logos are not yet implemented (no or SVGs), only text spans.
Attachments: a screenshot and the code snippet are central to understanding the setup.
Status: requester asks how to implement icon badges with the specified logic; no solution posted yet, discussion open.
Summarized with AI on December 12.
AI used: gpt-5.
{% if card_product.tags contains ‘Organic’ %}
Organic
{% if card_product.tags contains ‘Gluten free’ %}
Gluten free
{% if card_product.tags contains ‘Alt Meat’ %}
Alt Meat
{% endif %}
You can either use an svg or display an image there directly. In the case of the svg the code would end up looking like this
{% if card_product.tags contains ‘Organic’ %}
<svg> <!-- rest of the svg of the Organic icon --> </svg>
{% if card_product.tags contains ‘Gluten free’ %}
<svg> <!-- rest of the svg of the Gluten icon --> </svg>
{% if card_product.tags contains ‘Alt Meat’ %}
<svg> <!-- rest of the svg of the Alt Meat icon --> </svg>
{% endif %}
Or if you just want to use an image you can do the following:
In this case the code assumes you have the files organic-icon.png, gluten-icon.png, and alt-meat-icon.png in your theme’s assets folder. If your icons have a different name make sure to update the code accordingly.