This correct metafields shopify.country

I would to call metafields shopify.country
This correct way to call the value?

{% if product.metafields.shopify.country.value != blank %}

Grapes
{{ product.metafields.shopify.country.value }}
{% endif %}

Hi @GoDrinks-Bali

Yes, that is the correct syntax.

The format product.metafields.namespace.key.value is the standard way to access a metafield’s value in Liquid. Your code, {{ product.metafields.shopify.country.value }}, follows this structure perfectly.

Using an if statement to check if the value is blank before printing it is also an excellent practice.

Hope this helps!

But some reason, I got this result

image

That result means your metafield is not a simple text field but a list of metaobject references. To display the value, you need to loop through the list and then access the specific field you want from each object.

You will need to replace item.name with whatever the field key is in your metaobject definition (for example, it could be item.title).

{%- if product.metafields.shopify.country.value -%}
  <p>Grapes:</p>
  <ul>
    {%- for item in product.metafields.shopify.country.value -%}
      <li>{{ item.name }}</li>
    {%- endfor -%}
  </ul>
{%- endif -%}

Let me know how it goes.

Still not working, I think because this metafields direct from shopify? So we can’t call it on block?

Regardless of the origin, you should be able to see and screenshot for us the metafield and metaobject definitions.
This should help with field names and liquid code suggestions.
Is it like this?

Yes this one,

Then instead of

<li>{{ item.name }}</li>

try

<li>{{ item.label }}</li>

Can also try:

{{ product.metafields.shopify.country | metafield_text: field: "label" }}

This filter works with metaobject reference lists

Work will, for {{ product.metafields.shopify.country | metafield_text: field: “label” }}