I need to display a shopify metaobject value on the product card

Short description of issue

I need to display a shopify metaobject value on the product card

Link to Shopify Store

Reproduction steps

I need to display a shopify metaobject value on the product card. I seel wines and am using a Shopify metaobject to insert the wine region. I want to display the wine region on the product card. I can do this with a custom text metafield I created, but cant figure out how to do it with a metaobject from shopify

Additional info

I followed a tutorial: Displaying Metafields in Product Cards | Ed Codes

but it only works for custom text metafields

What type of topic is this

General discussion

Hey @Pelican_Bay ,

Are you assigning these through a metafield on the product?
Your store is password protected so we can’t see anything.

If you post a screenshot of your metaobject and metafield definition, I’d be happy to point you in the right direction.

Thanks!

I’m assigning the wine region through a metaobject definition created by shopify.
This is a different custom metafield I created and am able to display on product card:

      {%- assign momento = product.metafields.custom.momento -%} {%- if momento != blank -%}   <div class="product-momento" style="display: flex; align-items: center; gap: 6px;">     <img        src="https://cdn.shopify.com/s/files/1/0948/4566/5603/files/wine_8880557.png?v=1752667319"        alt="Wine icon"        width="14"        height="14"       style="display: inline-block;"     >     <span style="font-size: 14px; color: #574D61; line-height: 1.1;">       {{ momento.value }}     </span>   </div> {%- endif -%}

It’s a simple text metafield and it works fine, but I can’t figure out the right Liquid code to pull the field from the shopify metaobject: shopify.region

Hello @Pelican_Bay,

You need to rely on the metafield and metaobject definition:

  • You displayed a product metafield that already contains the information shopify.region, use it instead of creating another metafield custom.momento

  • You can have access to the label and taxonomy_reference fields. Here is some code to display what you need:
{% liquid
  assign region_list = product.metafields.shopify.region.value
  for region in region_list
    assign label = region.label.value
    assign taxonomy_reference = region.taxonomy_reference.value
    
    echo 'label: ' | append: label | append: ', taxonomy_reference: ' | append: taxonomy_reference | append: '<br>'
  endfor
%}

Thank you @teamdijon your reply was really helpful. I managed to display the region value on the product card.

Cheers

1 Like