How to call upon a Meta field in the new update 2.0?

Hi,

In the new update, I can not call upon a Meta field as I’ve done before.

I have a descriptive text under my product title on the collection page. However, now with the new update 2.0 it does not seem to work the same way.

I use to use code:

{{ product.metafields.my_fields.descriptive_text }}

To add my_fields.descriptive_text however, it does not work anymore.

Does anyone have a clue what I should do? I do not want to use Vendor to add this field since I need that field or google shopping (vendor).

To add: it shows up on all other pages that call upon the product card but not on the collection page :confused:

Kindest Regards,

Andy

Hi @Wibke_Loh ,

Keep in mind that OS 2.0 metafield types have slightly different behavior in terms of Liquid usage. For instance, one can use a code like this to access a “deprecated” metafield’s value:

{{ resource.metafields.namespace.key }}

However, this code would return an entire metafield object if used for “new” metafield types. Since an object can’t be displayed on the storefront, you need to access the value stored in that object:

{{ resource.metafields.namespace.key.value }}

Note that “.value” part right after the metafield key as it helps to access the value directly instead of getting the entire object.
In your specific case, you may want to replace this:


 {{ product.metafields.my_fields.descriptive_text }}

with:


 {{ product.metafields.my_fields.descriptive_text.value }}