Hi, all you clever people. I am sure this is an easy few lines of code! I know I could do what I want by adding this to each and every product description text, but I think a few lines of code will do it universally and quicker?
Is there a variable that can be used to check the “Tags” of a product? Something like?
{% if current_variant.inventory_TAG == “Bisque” %}
Please Note: - This item will need to be returned and fired
{% if current_variant.inventory_TAG == “Cast” %}
This item will require a 45 minute appointment. Please call to book
{%Else %}
Add Nothing
{% endif %}
So I want to add a line of text to all products, but changes depending if the product has a specific Tag.
If Product Tag list includes “Bisque” then show " Please Note: - This item will need to be returned and fired"
If Product Tag list includes “Cast” then show “This item will require a 45 minute appointment. Please call to book”
If Product Tag list include “WOW” then show “This item can be completed without visiting us”
etc
Hope that makes sense,
Thanks Barry
Hi @TheFunkyTeapot ,
This is the code for the tag logic:
{% assign productTags = product.tags | join:',' %}
{% if productTags contains "Your_Tag" %}
{%endif%}
Let me know if that works for you!
Fantastic! Don’t forget to Mark As Solution & Like to make the answer more visible to the community, Cheers!
1 Like
Could you expand on this solution? I’m looking to do the same thing; add a line of text in the product description “This work is currently on exhibit, please contact me for purchase ‘link to contact form’” when an artwork in my shop has the tag ‘exhibiting’. I have the Studio theme.
Hi there,
I came upon this solution and wanted to see if it could be taken a step further:
I’d like to define logic that adds a hyperlink into the descriptions of any products tagged with one of 50 specific tags. The link text/destination is different for each of those 50 tags.
Is it possible to use that same logic {% if productTags contains “Your_Tag” %} and add something to the effect of
% then add visible link text %
?
And then add a line for each of those 50 tags and its associated link destination/text.
And if the above is possible…where exactly would I add this code?
Many thanks in advance!
Noah