Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.
Solved

Shopify discount function apply to whole cart

JPastorOnestic
Shopify Partner
11 2 2

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
1801 266 387

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
1801 266 387

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
11 2 2

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!! 😄