Shopify discount function apply to whole cart

Solved
JPastorOnestic
Shopify Partner
6 0 1

Hello! Just created my first discount function extension by using this tutorial: https://shopify.dev/docs/apps/selling-strategies/discounts/experience/getting-started

 

Logic for applying the discount is about a customer has a tag (or not), but I can't make the discount target to whole cart, i made a workaround by setting target to all lines.

 

Docs talks about `orderSubtotal` don't know if that's I need, but `javy` compiler complains if I try to use it: https://shopify.dev/docs/api/functions/reference/order-discounts/graphql/common-objects/target

 

JPastorOnestic_0-1699280998062.png

 

If this field is not "my solution" and there is no way for setting up a cart discount instead cart lines discounts, please tell me. Thanks in advance!

Accepted Solution (1)
SBD_
Shopify Staff
Shopify Staff
1602 227 334

This is an accepted solution.

Hey @JPastorOnestic 

 

You'll want to create an order discount (instead of a product discount).

 

Let me know if you get stuck!

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 2 (2)
SBD_
Shopify Staff
Shopify Staff
1602 227 334

This is an accepted solution.

Hey @JPastorOnestic 

 

You'll want to create an order discount (instead of a product discount).

 

Let me know if you get stuck!

Scott | Developer Advocate @ Shopify 

JPastorOnestic
Shopify Partner
6 0 1

Hi!! Yes, that was the issue, i was following the tutorial that was using product discount function extension. Now restarting my Functions App and seems is working fine. Thanks!! 😄