Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi dear community !
I have an issue on the display of a metafield on my product detail page
I've created a new custom data :
I added it in a personnalized liquid section of my page
My problem is that it doesnt display the link to the collection I add to my product but it displays that :
I'm using the Dawn theme and the website is not opened at the moment
thanks for your help 🙂
Solved! Go to the solution
This is an accepted solution.
Here is the updated code:
{% for collection in product.metafields.custom.collectionsmulti.value %}
<a href="{{ collection.url }}">{{ collection.title }}</a><br>
{% endfor %}
Hi @gillesraw,
If you want to print your collection link here is the code above:
{% assign collection_handle = product.metafields.custom.collections.value.handle %}
{% assign collection = collections[collection_handle] %}
{% if collection %}
<a href="{{ collection.url }}">{{ collection.title }}</a>
{% endif %}
Hi ! thanks for your answer ! I made a mistake, I want to display a list of collections and not a single collection, so I created a new metafield named product.metafields.custom.collectionsmulti
I tried this but it doesnt work:
{% for collection_metafield in product.metafields.custom.collectionsmulti %}
{% assign collection_handle = collection_metafield.handle %}
{% assign collection = collections[collection_handle] %}
{% if collection %}
<a href="{{ collection.url }}">{{ collection.title }}</a><br>
{% endif %}
{% endfor %}
You're welcome! If you want to list collections, you don't necessarily have to create a metafield. Just use the provided code.
<div id="all_collection">
{% for collection in collections %}
<div class="single_collection_name"><span class="custom-design"><a href="{{ collection.url }}">{{ collection.title }}</a></span></div>
{% endfor %}
</div>
I have a metafield multivalued to display some categories linked to my product :
definition :
thanks again for your time 🙂
This is an accepted solution.
Here is the updated code:
{% for collection in product.metafields.custom.collectionsmulti.value %}
<a href="{{ collection.url }}">{{ collection.title }}</a><br>
{% endfor %}
thanks ! you're the best !!