How can I add metafields to my en.default.json file?

I’m trying to add metafields to my en.default.json file. Here is the code I’ve attempted to use:

"product_handle": "{{metafields.my_fields.cardtext}}"

And to call it I’m using:

{{'products.product.product_handle'  | t}}

I assume it’s not working because metafields is it’s own object but I’m not sure. Is there any way to accomplish this?

Hi @BenjerminPinale ,

It’s hard to say without the context, but I guess the problem might come from this part:

1.png

Since metafields are kinda “child” objects to main resources, you can’t access their data like that.

You should use the following syntax to access the metafield content:

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

Assuming you’re working with the product object, you should try this code:

{{ product.metafields.my_fields.cardtext.value }}

I figured as much. I’m unable to use the proper syntax because the “recent products”-cards(where I need to display metafield) are being displayed on the product template page and are rendered in with {%raw%} tags. So if I use the proper syntax it just shows the current products metafield for every “recent products”-card. I’m not sure where to find the javascript handling the rendering either.

I believe that your theme vendor might be able to help you. Have you tried reaching out to them? Since these guys are the ones who created your theme, they should be able to guide you in the right direction.

The theme is Impulse.

I’m reaching out the them now, but it doesn’t seem like the are going to answer because it’s related to feature changes but I’ll keep my fingers crossed.