How can I display SKU for specific product tags in confirmation emails?

Shopify Partner
2 0 0

Hello, I'm trying to put a code into a confirmation mail. Below the title of the product that is ordered it should show the SKU, but only for certain products with certain tags (men, women and unisex)


So this is what I wrote:



{% if product.tag contains 'men, women, unisex' %}

<p class="text-center uppercase">SKU: {{ line.variant.sku }}</p>

{% endif %}




However, it doesn't work.


Does anyone know what I'm doing wrong?


Kind regards,


Reply 1 (1)

Shopify Partner
6339 579 1345

This {% if product.tag contains 'men, women, unisex' %} will only try to match a tag against that singular product.tag with the exact text of "men, women, unisex" which isn't possible as commas are disallowed within a tags.


If "men, women, unisex" is mean to be individual tags then you need to match each individual tag.

Noting inconsistent use of uppercase/lowercase etc can cause inconsistent results.

And that "men" is ambiguous as it will match the text in both "men" and "women" so you may need to do exact string comparisons for each tag instead of using contains.


{% assign normalized_product_tag = product.tag | downcase %}

{% if normalized_product_tag contains 'men' or contains 'women' or contains 'unisex' %}



If your not looping over product.tags (plural) instead of product.tag (singular) you need to use product.tags 


{% assign normalized_product_tags = product.tags | join:", " | downcase %}

{% if normalized_product_tags contains 'men' or contains 'women' or contains 'unisex' %}


Save time & money ,Ask Questions The Smart Way

Confused? Busy? Get the solution you need

Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to