Output Based on Product Tags

This code will look at a products tags and output certain text if the product has one of the tags.

Please note: Using these code snippets may require some knowledge of HTML, CSS and Liquid. If you need assistance getting the code examples to work or meet your more specific needs, consider hiring a developer to help. These code snippets may not work in all themes or store configurations, so be sure to test everything thoroughly.

Mobile and Tablet Users: For best results, we recommend viewing this page on a desktop device.

Add this Code to My Content

Change the values in bold to fit your needs. Be sure the “use Liquid” checkbox is checked. Note that the code will only output the first match it finds.

{% if product.tags contains 'Tag 1' %}
Output Text 1
{% elsif product.tags contains 'Tag 2' %}
Output Text 2
{% else %}
Fallback Text
{% endif %}

If you want to output text for every tag a product matches, use this variation of code:

{% if product.tags contains 'Tag 1' %}
Output Text 1
{% endif %}
{% if product.tags contains 'Tag 2' %}
Output Text 2
{% endif %}