Hi! I want to use product tags to display custom messages on 'Collection pages under the products on Spotlight theme. I have already done this on Product page but am struggling to add the same message to the collection pages. Please help
Topic summary
A user is trying to display custom messages on collection pages in Shopify’s Spotlight theme based on product tags. They successfully implemented this on individual product pages using main-product.liquid with a loop checking for tags containing ‘newMessage:’. However, the same approach isn’t working when applied to card-product.liquid for collection pages.
Current Issue:
- The message displays correctly on product pages
- The message doesn’t appear on collection pages under product cards
- Related products show the message, but it doesn’t apply to the specific tagged product
Attempted Solutions:
- Initial suggestion to use
card_product.tagsin the liquid file - Follow-up recommendation to modify the code by looping through
card_product.tagsinstead ofproduct.tags
The discussion remains ongoing with troubleshooting focused on adapting the working product page code for collection page product cards.
Hi @mzwa
Dan here from Ryviu: Product Reviews @& QA app.
You can use this code in your card-product.liquid file
{% if card_product.tags contains 'your tag' %}
your message
{% endif %}
Unfortunately no changes with the code you gave. I used the following code on the main-product.liquid for the message on the product page which worked successfully.
{% for tag in product.tags %}
{% if tag contains ‘newMessage:’ %}
{{ tag | remove:‘newMessage:’}}
{% endif %}
{% endfor %}
When I put this in the card-product.liquid file I don’t see the message it in the collection page. I do see a message in the product page on the related products (the same message displayed under the product page on that particular product page ). This message under the related products doesn’t apply to that particular product. Please help
You can try to edit this
{% for tag in card_product.tags %}
{% if tag contains 'newMessage:' %}
{{ tag | remove:'newMessage:'}}
{% endif %}
{% endfor %}