Label link not working

Solved

Label link not working

PK2023
Excursionist
52 1 7

Hi,

 

In my "product-item" snippet I tried to create a image label with a link that leads to a collection. However the link is not working and clicking it only opens the product page.

The odd thing is that I have previously created almost identical label to the same snippet and it works like a charm. The only difference between these two is that the working one loops through collection and the broken one loops through tags. The image is however showing in the broken one so the looping works like it should. Would someone help me to figure out why the broken link is not linking?

 

Broken code:

{%- for tag in product.tags -%}
{%- if tag contains 'book' -%}
<a href="/collections/tulips" style="position:relative; z-index:1;"><img src="https://cdn.shopify.com/s/files/1/0651/0890/2100/files/book_icon_e827c9f4-1c6b-43d1-8c1d-9102a88ee47..." width="20px;"height="20px;" style="margin:0;"></a>
{%- endif -%}
{%- endfor -%}

 

Working code: 

{% for collection in product.collections %}
{% if collection.title contains "The bulbs of the future" %}
<a style="margin-bottom: 45px !important;" class=" product-item__quick-buy-button hidden-lap-and-up" href="/collections/nlg" ><img src="https://cdn.shopify.com/s/files/1/0587/8307/2392/files/IMG_1074.jpg?v=1721909176" style="width:25px;"></a>
<a class="product-item__quick-buy-button hidden-tablet hidden-phone" href="/collections/nlg" ><img src="https://cdn.shopify.com/s/files/1/0587/8307/2392/files/IMG_1074.jpg?v=1721909176" style="width:25px;"></a>

{% endif %}
{% endfor %}

 

Thanks!

Accepted Solution (1)

PK2023
Excursionist
52 1 7

This is an accepted solution.

Figured out this myself no need for help anymore 🙂

View solution in original post

Replies 6 (6)

AnneLuo
Shopify Partner
1293 228 266

Hi, @PK2023 

Can you please share the store URL so that I can assist you?

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me   

Buy Me A Coffee

PK2023
Excursionist
52 1 7

Hi,

 

It is only in a test theme so sharing link doesn't work 🙂 

I am just wondering if there is something very obvious I am doing wrong.

Huptech-Web
Shopify Partner
1161 232 263

Good day, @PK2023. Could you kindly provide me with the link to your store?

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
PK2023
Excursionist
52 1 7

Hi,

It is only in a test theme so sharing link doesn't work 🙂 

I am just wondering if there is something very obvious I am doing wrong.

PK2023
Excursionist
52 1 7

This is an accepted solution.

Figured out this myself no need for help anymore 🙂

oscprofessional
Shopify Partner
16346 2438 3180

Hey @PK2023 

The issue you're experiencing might be due to how the link or the tag is being processed in the product-item snippet. Here are a few things to check and try:

1. Check Z-Index and Overlapping Elements

2. Ensure Tag Logic is Correct

You can test this by adding a simple text link inside the loop to see if it's clickable:

 

{%- for tag in product.tags -%}
  {%- if tag contains 'book' -%}
    <a href="/collections/tulips">Tulips Collection</a>
  {%- endif -%}
{%- endfor -%}

 

If the text link works, the issue might be related to the image or its styling.

3. Try a Different Approach

 

{%- for tag in product.tags -%}
  {%- if tag contains 'book' -%}
    <div style="position: relative;">
      <a href="/collections/tulips">
        <img src="https://cdn.shopify.com/s/files/1/0651/0890/2100/files/book_icon_e827c9f4-1c6b-43d1-8c1d-9102a88ee47..." width="20px" height="20px" style="position: relative; z-index: 1;">
      </a>
    </div>
  {%- endif -%}
{%- endfor -%}

 

 

Hire us | Pass Core Web Vital | B2B Wholesale Experts | Claim Your Free Website Review |
Connect with Us: WhatsApp | Skype: oscprofessionals-87 | Email: pallavi@oscprofessionals.com |
Custom Shopify SolutionsPrivate Apps, Theme Customization & SEO | Digital Marketing |
OSCP Apps: Discount Suite | Wholesale App | Bundle & Upsell | Shipping Discount | and more...