Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Accessing app-data metafields in checkout ui extension.

Accessing app-data metafields in checkout ui extension.

Turbofan1178
Shopify Partner
57 4 17

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.
Founder, WC: Invite To WhatsApp Channel
- Invite customers to join your WhatsApp channel with a single click
- Boost outreach message open rates
- Grow sales with direct outreach on WhatsApp channels
Replies 8 (8)

Liam
Community Manager
3108 344 910

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. 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Turbofan1178
Shopify Partner
57 4 17

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.

Founder, WC: Invite To WhatsApp Channel
- Invite customers to join your WhatsApp channel with a single click
- Boost outreach message open rates
- Grow sales with direct outreach on WhatsApp channels
Steve_Honey
Shopify Partner
3 0 4

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 😂

mike_signorella
Shopify Partner
8 0 5

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.

baggio_giacomo
Shopify Partner
24 1 3

Hi @Liam !

 

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

Steve_Honey
Shopify Partner
3 0 4

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

baggio_giacomo
Shopify Partner
24 1 3

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

Leocxy
Shopify Partner
10 1 3

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"