New Shopify Certification now available: Liquid Storefronts for Theme Developers

Discount Functions Input: get product collections list

ArtemFokin
Shopify Partner
3 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 2 (2)
lizk
Shopify Staff
Shopify Staff
246 57 62

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
3 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.