I set the fields in “shopify.extension.toml”
[extensions.input.variables]
namespace = "$app:test_namespace"
key = "test_key"
I use CreateAppDataMetafield mutation to create/set the metafield. When I use the namespace: “$app:test_namespace”, I get an error: “Unexpected system error. Try again later.”
If I remove $app and use namespace: “test_namespace” I don’t see the error.
But then I want to get this value in my input.query in cart-transform
I am trying to get this value in two ways
1 way
query Input {
cartTransform {
test: metafield(namespace: "$app:test_namespace", key: "test_key") {
value
}
}
}
2 way
query Input {
cartTransform {
test: metafield(namespace: "test_namespace", key: "test_key") {
value
}
}
}
None of them works and returns null value
I can see the value from this metafile on the liquid file through the theme-extension
Do you know how I can retrieve and set this metafield?
1 Like
There are two issues here:
- You are trying to set a metafield where the
ownerId is your app installation. Nothing wrong with that, but the error you are getting **Unexpected system error. Try again later.**, which has a very useless error message, is due to the fact that when setting app metafields, the $app part of the namespace is not needed, because it’s already an app owned metafield since its owner is your app, so adding $app: would be redundant.
- You are creating a metafield that has
ownerId your app installation instead of the cart transform object.
You should create a cart transform using the cartTransformCreate mutation, then once you have the cart transform id (which should look something like this gid://shopify/CartTransform/<id>) you can go ahead and run the metafieldSet mutation with the ownerId variable as the cart transform id instead of your app installation id.
Hope this helps!
Hi there, I don’t find the way to get the cartTransform Id after it has been created, could you share some code examples on how to get it? and how to call it from the cart-transform extension?