Re: How to put collection name to vendor?

How to put collection name to vendor?

Vlk1
Excursionist
23 1 0

Hey guys, I might need your help with something. I am looking for solution how to add to vendor collection name. I have found this code and put it to main product liquid: 

{% for collection in product.collections %}
<p class="collection-title">{{ collection.title }}</p>
{% endfor %}

It is working just fine BUT If the product has more collection, then it shows all of them. Is there any solution how to edit this code to show only one collection and not all of them? Thank you

Vlk1_0-1717436319977.png

 

Replies 5 (5)

EBOOST
Shopify Partner
1223 319 365

Hi @Vlk1 ,

May I suggest 2 solutions below:

1. code to  show the first collection

 {%  assign collection = product.collections | first %} 
{{ collection.title }}

2. Add "within: collection" to url of product. In product liquid only use {{ collection.title }} to show it.

 

EBOOST_0-1717515674694.png

 

- Hope can help. If you find my reply helpful, please hit Like and Mark as Solution
- Need a Shopify developer? Contact email: eboost10@gmail.com
- Visit our site: https://www.eboosttech.net to view and download shopify themes and magento2 extensions free
- ❤❤DONATE ❤❤Coffee tips
Vlk1
Excursionist
23 1 0

Hey, thank you. I am not sure if I got it right but when I put it to product liquid, nothing happend. 

 

Vlk1_0-1717588489829.png

 

EBOOST
Shopify Partner
1223 319 365

Hi,

If you used in Assets/card_product.liquid. May I suggest code below:

 {%  assign collection = card_product.collections | first %} 
{{ collection.title }}

EBOOST_0-1717591558612.png

 

- Hope can help. If you find my reply helpful, please hit Like and Mark as Solution
- Need a Shopify developer? Contact email: eboost10@gmail.com
- Visit our site: https://www.eboosttech.net to view and download shopify themes and magento2 extensions free
- ❤❤DONATE ❤❤Coffee tips
Vlk1
Excursionist
23 1 0

Vlk1_0-1717593898683.png

I have edited it but it shows still name of my store as a vendor, not collection

EBOOST
Shopify Partner
1223 319 365

Hi,

Could you please share your store url that you applied code?

- Hope can help. If you find my reply helpful, please hit Like and Mark as Solution
- Need a Shopify developer? Contact email: eboost10@gmail.com
- Visit our site: https://www.eboosttech.net to view and download shopify themes and magento2 extensions free
- ❤❤DONATE ❤❤Coffee tips