Accessing app-data metafields in checkout ui extension.

I created an app-data metafield in an embedded app and I want to access it in the checkout ui extension but I’m unable. I’ve tried using `

useMetafields, useAppMetafields, useMetaFields but no of them works. What can I use to access app-data metafields on the checkout ui extension.

2 Likes

Hi - app-data metafields are currently not supported in checkout extensions. Only the metafields linked to the resources noted in this dev doc are supported - however we’re planning on including app-data metafields in future versions.

2 Likes

Okay makes sense.

Basically what I’m trying to do is surface some app settings in my checkout ui extension that is modified by the merchant in the embedded app version of my app. What is the ideal/best practices way to achieve this. I read somewhere that you could use the Shop object to store metafields [https://github.com/Shopify/ui-extensions/discussions/1031]. Is that a good idea? How are the metafields kept private to only my app? How do I even do this?

Thank you.

1 Like

Is there any roadmap item for supporting app data/reserved metafields in checkout UI extensions (and functions while we’re at it). It seems like any obvious fit, not to mention some seriously confusing language - I pulled my hair out for quite a while before realising that $app: namespaced metafields cannot be surfaced in $appmetafields :joy:

2 Likes

From my understanding

You can use useMetaFields to access public Shop Meta.

# the below configs come from "shopify.extension.toml"

# this not work
[[extensions.metafields]]
namespace = "$app:product-discount"
key = "config"

# this work, you can remove 'xxxx' and 'yyyy' to your variables
[[extensions.metafields]]
namespace = "xxxx"
key = "yyyy"
1 Like

This is an egregious omission. It’s extremely confusing and counterintuitive that app namespaced metafields are not available in the appmetafields variable… I spent hours trying to figure this out.

5 Likes

Hi @Liam !

Any news on this? Have you decided if you want to include app-data metafields in customer account API?

I believe Customer Account UI extensions can utilize app namespaced metafields already, see https://shopify.dev/docs/apps/build/customer-accounts/metafields

That is slightly different. In his case he creates a metafield definition with customer as owner with an app reserved namespace

In my case I have to fetch (and then mutate) a metafield with app as owner (when creating the metafield definition, you use the app installation id as ownerId)

I think that the only way to da that is to migrate to a shop metafield