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.
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?
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
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"
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.
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