All things Shopify and commerce
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,
Solved! Go to the solution
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 %}
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.
Shall I remove all the IF in the code then ? I'm not even exactly sure what they do.
It doesn't seem to work. The link is now https://recallclothing.com/collections/CollectionDropCollectionDropCollectionDropCollectionDrop
- 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.
Not working apparently. See below. Do you have another idea ?
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 %}
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.
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024