Why isn't my metafield displaying correctly on my product detail page?

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 :slightly_smiling_face:

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 %}
  {{ collection.title }}
{% 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 %}
{{ collection.title }}

{% 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.


  {% for collection in collections %}
  
{{ collection.title }}
     
  {% endfor %} 

I have a metafield multivalued to display some categories linked to my product :

definition :

thanks again for your time :slightly_smiling_face:

Here is the updated code:

{% for collection in product.metafields.custom.collectionsmulti.value %}
{{ collection.title }}

{% endfor %}

thanks ! you’re the best !!