shopifyliquidmetaobject

Displaying Multiple Entry Product Metaobjects in Shopify


Metaobject Display Issue: Single vs. Multiple Entries"

I have a question regarding product-related metaobjects. I've created a metaobject that is linked to a product, and I'm able to display it using this syntax: {{ product.metafields.custom.test_avis.value.title }}. This works because it's a metafield with a single entry for each product.

However, I also have another metaobject named "avis_produit" which has multiple entries for a single product. Unfortunately, I'm unable to display it using the code: {{ product.metafields.custom.avis_produit.value.client }}. How can I go about displaying it correctly?


Solution

  • You can use for loop to get the values like below,

          {% for avis_produit in product.metafields.custom.avis_produit.value %}
    
                <div>
                  {{ avis_produit.client }}
                </div>
    
          {% endfor %}
    

    If you need any specific value then you can use "assign", "capture" and conditional statements as per you need