Link to Vendor Collection from Product Page

Solved

Link to Vendor Collection from Product Page

elgobbo
Excursionist
21 2 2

Hi,

 

I would like to change the URL query when someone click on the link vendor in the product page.

 

Currently, the link to a specific vendor in the product page links to 

https://recallclothing.com/collections/vendors?q=vendor name

 

I would like it to link to

https://recallclothing.com/collections/vendor name

 

Here is the code from product.liquid which is used for this link

 {% if product.vendor %}
<div class="product__block__text" style="--PB: {{ block.settings.padding_bottom }}px;" {{ block.shopify_attributes }}>
   {% if block.settings.add_vendor_link %}
      <p><a href="{{ product.vendor | url_for_vendor }}" class="product__form__link">{{ product.vendor }}</a></p>
   {%- else -%}
      <p class="product__form__link">{{ product.vendor }}</p>
   {% endif %}
      </div>
   {% endif %}

Does anyone know how to modify it ?

Many thanks,

Accepted Solution (1)
elgobbo
Excursionist
21 2 2

This is an accepted solution.

Solved with:

 

{% if product.vendor %}
  {% assign its_a_match = false %}

  {%- capture my_collection_handle -%}{{ product.vendor | handleize | strip | escape  }}{%- endcapture -%}
  {% assign my_collection_handle_stripped = my_collection_handle | strip | escape %}

  {% unless collections[my_collection_handle_stripped] == blank %}
    {% assign its_a_match = true %}
  {% endunless %}

  <div class="product__block__text" style="--PB: 20px;" >
    {% if its_a_match %} 
      <a href="{{ routes.collections_url }}/{{ my_collection_handle }}" class="product__form__link">{{ product.vendor }}</a>
    {% else %}
      <a href="{{ product.vendor | url_for_vendor }}" class="product__form__link">{{ product.vendor }}</a>
    {% endif %}
  </div>
{% endif %}

View solution in original post

Replies 7 (7)

Dan-From-Ryviu
Shopify Partner
9145 1829 1863

You can try to update the code to this and check if it works

 

<div class="product__block__text" style="--PB: {{ block.settings.padding_bottom }}px;" {{ block.shopify_attributes }}>
      <p><a href="https://recallclothing.com/collections/{{ product.collections }}" class="product__form__link">{{ product.collections }}</a></p>
</div>

 

- Helpful? Like and Accept solution! ‌Support me: Buy coffee
- Ryviu - Reviews & QA app, collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy app: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

elgobbo
Excursionist
21 2 2

Shall I remove all the IF in the code then ? I'm not even exactly sure what they do.

elgobbo
Excursionist
21 2 2
Dan-From-Ryviu
Shopify Partner
9145 1829 1863
Please just use the code I sent

- Helpful? Like and Accept solution! ‌Support me: Buy coffee
- Ryviu - Reviews & QA app, collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy app: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

elgobbo
Excursionist
21 2 2

Not working apparently. See below. Do you have another idea ?

 

Screenshot 2023-12-19 at 16.53.34.pngScreenshot 2023-12-19 at 16.54.06.png

elgobbo
Excursionist
21 2 2

This is an accepted solution.

Solved with:

 

{% if product.vendor %}
  {% assign its_a_match = false %}

  {%- capture my_collection_handle -%}{{ product.vendor | handleize | strip | escape  }}{%- endcapture -%}
  {% assign my_collection_handle_stripped = my_collection_handle | strip | escape %}

  {% unless collections[my_collection_handle_stripped] == blank %}
    {% assign its_a_match = true %}
  {% endunless %}

  <div class="product__block__text" style="--PB: 20px;" >
    {% if its_a_match %} 
      <a href="{{ routes.collections_url }}/{{ my_collection_handle }}" class="product__form__link">{{ product.vendor }}</a>
    {% else %}
      <a href="{{ product.vendor | url_for_vendor }}" class="product__form__link">{{ product.vendor }}</a>
    {% endif %}
  </div>
{% endif %}
Dan-From-Ryviu
Shopify Partner
9145 1829 1863

Please update code to this and check again

{% if product.collections.size > 0 %}
  {% for collection in product.collections %}
<div class="product__block__text" style="--PB: {{ block.settings.padding_bottom }}px;" {{ block.shopify_attributes }}>
           <p><a href="{{ collection.url }}" class="product__form__link">{{ collection.title }}</a></p>    
</div> 
 {% endfor %}
{% endif %}

- Helpful? Like and Accept solution! ‌Support me: Buy coffee
- Ryviu - Reviews & QA app, collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy app: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.