Hello, i’m trying to use checkout validation function with query input variables as it described in the docs
https://shopify.dev/docs/apps/functions/input-output/variables-queries
First of all, there is absolutely unclear information about how to find ownerID. But as i’ve reed on the community forum - Shop is the owner.
But it doesn’t work, i see metafields in the shop, but inAnyCollection filter still return False, when True is expected
Here is a quick sample for it
Query Input (run.graphql)
query RunInput($protectedCollectionsIds: [ID!]) {
cart {
lines {
merchandise{
__typename
… on ProductVariant {
id
product {
id
inAnyCollection(ids: $protectedCollectionsIds)
}
}
}
}
}
shop{
protectedCollectionsIds: metafield(namespace: “$app:nifty-bridge”, key: “protectedCollectionsIds”){
value
}
}
}
Function config(shopify.extension.toml)
[extensions.input.variables]
namespace = “$app:nifty-bridge”
key = “protectedCollectionsIds”
MetaieldsSet input
{
key: “protectedCollectionsIds”,
namespace: $app:${METAFIELDS_NAMESPACE},
ownerId: shopifyShopGId,
type: “json”,
value: JSON.stringify({ protectedCollectionsIds }),
}
Output
i can receive protectedCollectionsIds in the shop metafields
shop{
“protectedCollectionsIds”: { “value”: “{"protectedCollectionsIds":["gid://shopify/Collection/477600842047"]}” }
}
But inAnyCollection in input still False for the product
If i will set default value for $protectedCollectionsIds from metafields
query RunInput($protectedCollectionsIds: [ID!]=[“gid://shopify/Collection/477600842047”])
inAnyCollection will be True, as expected
Can someone help me to figure out how to work with it?
I’ve tried with discount functions and it works as expected.