Shopify Functions Product Discount API - get the collection ids of a product

Topic summary

The discussion centers on accessing product collection IDs within Shopify Functions APIs (Product Discount API and CartTransform API).

Core Challenge:

  • Developers need to determine if a product belongs to specific collections eligible for discounts when implementing Mix & Match bundles
  • Collection IDs are not directly available in the API’s product object input
  • Performance constraints prevent retrieving all collection IDs for products

Technical Context:

  • The function runs on Shopify’s infrastructure as part of a contract between the app and Shopify
  • Backend app-defined offers aren’t accessible from the function execution environment
  • The inAnyCollection field exists in the contract but doesn’t solve the access issue

Proposed Solution:

Summarized with AI on November 19. AI used: claude-sonnet-4-5-20250929.

Hey all!

Ohad here, from Zoorix. Maybe you can help us here :slightly_smiling_face:

We are wondering if there is a way to find the collection ids of a product using the Shopify Functions Product Discount API - https://shopify.dev/docs/api/functions/reference/product-discounts/graphql/common-objects/product

Cheers!

Ohad

To give more context, we are trying to implement the Mix & Match bundle using the Shopify Functions Product Discount API or the CartTransform API, and on both APIs, we are not able to understand how to know if a product is part of a collection that is eligible for a discount. Here is the Input of the CartTransform API - https://shopify.dev/docs/api/functions/reference/cart-transform/graphql/common-objects/product.

We understand that it’s not possible to receive all the collection ids due to performance considerations, and that’s why the inAnyCollection comes to help. The issue here is that the inAnyCollection is part of the contract and between the app and Shopify, runs on the Shopify end, and we don’t have access there to the offers that are defined on the app backend.

I hope that makes sense, and let me know if there’s any additional input that can help on my end.

Cheers,

Ohad

Hello @ohadsc !

Your question got me in the right direction to achieve this for a Discount Function. Maybe it can be done in your scenario too. I know this is an old question, but maybe it can help others that get here through search engines.

My goal was to apply a discount function in specific product collections and I did it by setting a variable for the input query. This is how it is done https://shopify.dev/docs/apps/functions/input-output/variables-queries#step-3-use-the-metafield-as-input-query-variables

Looks like it would work for Cart Transform API too. Hope it helps somebody.