Personalized checkout and custom promotions with Shopify Scripts
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,
Thomas
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' %}
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024