Discount Functions Input: get product collections list

ArtemFokin
Shopify Partner
9 0 0

Hello, I'm trying to implement auto discounts based on collections, but I don't see the way to check if product has specific collection. I've checked docs
https://shopify.dev/docs/api/functions/reference/product-discounts/graphql/common-objects/product#im...

we can use  "inAnyCollection" in Input, but I will receive list of collections in metafields, so I need to check it later, in function body.

 

I can create product metafield which contains this information and update it on every product update, maybe, but it's sounds 

 

Why we can't just receive list of collections which product included in? I don't think that product have a lot of them.

Or just set collections in the output targets

Replies 3 (3)

lizk
Shopify Staff
246 57 70

Hi there 👋

Could you confirm the exact functionality you are looking to build. 

If you are looking for all products to be discounted that are in certain collections this can be done with the built in discount configurations, and does not need to be implemented with functions.

To learn more visit the Shopify Help Center or the Community Blog.

ArtemFokin
Shopify Partner
9 0 0

Hi 
We build widget for merchants and we need to apply auto-discount only for specific products in collections. Now we use one-time discount codes for this purposes, but it's a bit mess and also inconvenient for clients.
It will be cool to have an option to apply function discount for specific collection in the cart as we have in code-discounts.

SomeUsernameHe
Shopify Partner
468 53 89

Were you ever able to figure this out? I am running into the same problem right now and cannot find an easy solution to this.

Have I helped? Consider putting coffee in my mouth!
Buy Me a Coffee