Accessing app-data metafields in checkout ui extension.

Accessing app-data metafields in checkout ui extension.

Turbofan1178
Shopify Partner
51 4 8

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.
DK
Replies 5 (5)

Liam
Shopify Staff
2839 311 810

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
51 4 8

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.

DK
Steve_Honey
Shopify Partner
2 0 1

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
6 0 3

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.

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"