Display metaobject in liquid

I have a metaobject called beekeeper, which has 4 fields - name, location, profile_image, total_hives. This metaobject is linked to a product via metafield called hive.beekeeper

The issue is that I cannot display meta values. The closes I got was with {{ card_product.metafields.hive.beekeeper }}, where I at least got gid://shopify/Metaobject/72501821775 in response.

I need to display name value. Dawn Theme. Please help

Hello @mybzzfarm ,

Can you please share few screen-shots how and where you created metaobjects?
or a short video ?

Thanks

Hi,

I do apologise I couldn`t reply earlier. Please see screenshots below.

Also, I did make a little bit of progress by using this bit:

{% for beekeeper in shop.metaobjects.beekeeper.values %}
        
        
        

          
            

{{ beekeeper.name.value }}

            

{{ beekeeper.location.value }}

            

Total Hives: {{ beekeeper.total_hives.value }}

          

      {% endfor %}

But of course it iterates and displays all entries, whereas I simply cannot figure out how to better write IF statement to display only entry assigned to the current product (it`s to be displayed on a product card within collection, not on a product page).

Hope you can help me.

This is what I`m trying to achieve: every hive is assigned with beekeeper, and I want to display a small icon of a beekeepers profile picture. At the moment, since the loop iterates through all entries, you can only see the latest one, but I need something to define “if this product is assigned with this entry from metafield, then display this info”

Hello. Please try this for all the information show on product collection page.

{% if card_product.metafields.custom.hive.beekeeper %}
  {% assign beekeeper = shop.metaobjects.beekeeper[card_product.metafields.custom.hive.beekeeper] %}
  
  {% if beekeeper %}
  
    {% if beekeeper.profile_image != blank %}
    
    {% endif %}
    

    
      {% if beekeeper.name != blank %}
      

{{ beekeeper.name }}

      {% endif %}
      {% if beekeeper.location != blank %}
      

{{ beekeeper.location }}

      {% endif %}
      {% if beekeeper.total_hives != blank %}
      

Total Hives: {{ beekeeper.total_hives }}

      {% endif %}
    
      
    

  {% else %}
    
    

Beekeeper information not available.

  {% endif %}
{% endif %}

You may use only product instead of card_product for product page.

Try this for collection cards:

{% if card_product.metafields.custom.hive.beekeeper %}
  {% assign beekeeper = shop.metaobjects.beekeeper[card_product.metafields.custom.hive.beekeeper] %}
  
  {% if beekeeper %}
  
    {% if beekeeper.profile_image != blank %}
    
    {% endif %}
    

  {% endif %}
{% endif %}

Hey guys,

I try to display new shopify metaobjects with liquid code.

I would like to show the content of the field “Informationen zu Allergenen”. Which could be “Sulfite”, “Nuts”, “Egg” and so on..

What variable do I need to use to show it in custom liquid inside the customizer?

I’m running into the same issue. I tried a lot to show the allergens. But, no luck so far. Anyone has a solution?

As you can see in the screenshot, the field has the namespace “shopify.allergen-information”.

You can therefore access this field under the following objects:

  • product.metafields.shopify[‘allergen-information’]

  • item.product.metafields.shopify[‘allergen-information’]

  • card_product.metafields.shopify[‘allergen-information’]

{% for field in product.metafields.shopify['allergen-information'].value %}
  {{ field.label }}
{% endfor %}

The contents in metafields are accessible under the value namespace. Since it is a list, you iterate with a for loop.