Custom price rules for discounts

Custom price rules for discounts

gd_silva
Shopify Partner
2 0 1

Hi,

 

I'm trying to create some custom rules for discount codes, via the Shopify API, and could use some help with this. I've tried support but they could not help.

 

Imagine the store has 3 products - product A, product B and product C. These would be the conditions for the price rule:

 

- Discount code applies -100% on 1 unit of product A and 1 unit of product B.

- Discount code only applies if there are at least 1 unit of product A and 1 of product B in the checkout cart.

- If other products (e.g. more units of those 2 or even product C) are added to the cart, those are billed normally and discount does not apply to them.

 

Is this even possible to implement using the properties of price rules?

 

Best,

Gonçalo

Replies 3 (3)

ShopifyDevSup
Shopify Staff
1451 238 497

Hey @gd_silva, you should be able to create a price rule based on the use case you outline above. Using the PriceRule resource you'd want to set line_items as the "target" value and assign the products you want the discount to apply to as the values for either the "entitled_products" or "entitled_variants" fields after setting the Price Rule's "target_selection" to "entitled". 

This would effectively make it so that when a customer applies the discount it would only apply to the specific products and not to any others, like you mentioned in your initial post. Hope this helps - let us know if we can clarify anything on our end for you! 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

gd_silva
Shopify Partner
2 0 1

Hi, @ShopifyDevSup, thanks for your response. It put me in the right direction but I'm not still there. Using those options (check the JSON payload below) does not really apply all the conditions I need, since it would apply to any number of units of each of the entitled products.

 

I'm already using the entitled collection IDs property but I still need to apply the discount to only 1 unit of each of the entitled collections (I have 2, A and B). And the discount should apply to 1 unit of collection A and 1 unit of collection B, even if there are more units of products belonging to those collections in the cart.

 
Is this possible?

 

 

 

 

 

ShopifyDevSup
Shopify Staff
1451 238 497

Hi @gd_silva, perhaps choosing the discount to apply 'across' the products selected would resolve this issue if you are working with collections. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog