Shopify Functions Input Variables

Topic summary

Main issue: A developer implementing a cart/checkout Shopify Function using input query variables can’t get inAnyCollection to return true for a product that is in a collection, and is unsure which ownerId to use for metafieldsSet. They aim to set/read collection metafields for use as variables in the function.

Context and attempts: Screenshots show configuration following the Shopify docs for Functions input variables. The product appears in the target collection and collection metafields are visible in responses, but inAnyCollection remains false.

Latest guidance: For a validation function, the owner for metafields should be the validation object (Admin GraphQL: validation query, validationCreate, validationUpdate). If a UI extension is created for the validation, the metafield can be added there as well.

Outcomes and status: The ownerId question is addressed (use the validation object). No confirmed fix for the inAnyCollection false result. Discussion remains open with unresolved behavior regarding collection membership check. Screenshots are central to demonstrating the setup and the unexpected response.

Summarized with AI on December 28. AI used: gpt-5.

Hello I’m developing the cart and checkout Shopify function and using the variables in input queries
I’m not finding proper documentation, Currently I’m following this documentation https://shopify.dev/docs/apps/functions/input-output/variables-queries
I want the same functionality as in the documentation. Which owner id I should have to pass here?

I have followed these steps as per documentation:
1.

The product is in the collection but I’m not getting true in the response of inAnyCollection
also I have get the metafields in the response you can see the collection values of the metafields

I want to set metafields of collection list for the cart and checkout function in the background, in the app and want to check that metafields in my cart checkout function as a variable
I have followed the documentation proper but not getting correct response
Please suggest me if my doing wrong, and which type of owner id should pass in the metafieldsSet mutation

Hi @sbdev

As this appears to be a validation function, the owner would be the validation object.

https://shopify.dev/docs/api/admin-graphql/2024-04/queries/validation
https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/validationCreate

https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/validationUpdate

If you create a UI extension for your validation, you can add the metafield within that as well.

-Nick