Hi Shopify Community,
I’m working on a Shopify Discount Function targeting:
cart.lines.discounts.generate.run
and I’m trying to determine whether a cart line’s product belongs to a specific collection.
GraphQL Input Query
query CartInput($CollectionIds: [ID!]) {
cart {
lines {
merchandise {
... on ProductVariant {
id
product {
id
title
handle
collectionIds: inCollections(ids: $CollectionIds) {
collectionId
isMember
}
}
}
}
}
}
}
Extension Configuration (shopify.extension.toml)
[extensions.input.variables]
namespace = "$app:discount-bogo"
key = "CollectionIds"
Runtime Input (Logged)
"product": {
"id": "gid://shopify/Product/11007581258046",
"title": "Check Blazer",
"handle": "3905-jacket-in-black",
"vendor": "PERFORMAX",
"collectionIds": []
}
Issue
Even though the product is definitely part of the collection,
the response always returns:
"collectionIds": []
No isMember, no collectionId, nothing.
This happens specifically when:
-
The function runs in POS
-
Using
cart.lines.discounts.generate.run -
Passing collection IDs via
extensions.input.variables
What I Need
I need a reliable way inside a Discount Function to check whether a product belongs to a collection.
So my questions are:
-
Is
inCollectionssupported in discount function runtime, especially for POS? -
Are
extensions.input.variablesguaranteed to be available forinCollections? -
Is this a known limitation of Shopify Functions where collection membership isn’t resolvable?
-
If
inCollectionsis not supported, what is the recommended alternative to check product–collection relationships inside a discount function?
Any clarification from Shopify staff or anyone who’s solved this would be appreciated.
Thanks.
FULL INFO
cart_lines_discounts_generate_run.graphql
query CartInput($CollectionIds: [ID!]) {
cart {
posCheck: attribute(key: "discountlyPos") { value }
lines {
id
cost {
amountPerQuantity {
amount
}
subtotalAmount {
amount
}
}
quantity
merchandise {
... on ProductVariant {
id
product {
id
title
handle
vendor
collectionIds: inCollections(ids: $CollectionIds) {
collectionId
isMember
}
}
__typename
}
}
}
}
discount {
discountClasses
}
shop {
metafield(key: "DiscountlyBogoDiscountPOS", namespace: "ACPTiered") {
jsonValue
}
subTotalMeta:metafield(key: "NormalTiers", namespace: "ACPTiered") {
jsonValue
}
localTime{
date
}
}
}
shopify.extension.toml
api_version = “2025-10”
[[extensions]]
name = “t:name”
handle = “discount-function-XXXX”
type = “function”
uid = “4811fdbc-7d6b-0de0-6721-XXXXX”
description = “t:description”
[[extensions.targeting]]
target = “cart.lines.discounts.generate.run”
input_query = “src/cart_lines_discounts_generate_run.graphql”
export = “cart-lines-discounts-generate-run”
[[extensions.targeting]]
target = “cart.delivery-options.discounts.generate.run”
input_query = “src/cart_delivery_options_discounts_generate_run.graphql”
export = “cart-delivery-options-discounts-generate-run”
[extensions.build]
command = “”
path = “dist/function.wasm”
[extensions.input.variables]
namespace = “$app:discount-bogo”
key = “CollectionIds”