Validating discounts at checkout

Validating discounts at checkout

mss_developer
Shopify Partner
3 0 0

I am trying to find a way to validate the discount that is apply to a cart in a checkout validation function, but... I can't find any way to get the discount codes that have actually been apply. I would expect I have receive those in the Input to the function, but I can't see any fields in the GraphQL API to support this.

Does anyone know how I can get the discount codes that have been applied to a cart in a shopify function?

Thanks

Replies 3 (3)

tobebuilds
Shopify Partner
527 39 141

Shopify Functions can't query which discounts have been applied to the cart.

 

Relevant discussion: https://github.com/Shopify/function-examples/discussions/574

 

Maybe you can try a Checkout UI extension?

Founder, Regios Discounts app (4.8 stars, 81 reviews, Built for Shopify)
- Custom discounts made simple
- "Just about any discount you'll ever need"
- Built by an ex-Google software engineer
mss_developer
Shopify Partner
3 0 0

Damn, that is a real shame. I'm finding I have to "workaround" so much.

Thanks for the quick reply

mss_developer
Shopify Partner
3 0 0

Hi Abel,

 

This is really a case of me wanting the server to validate the logic rather than the UI. I kind of ignored the client side solution because of this, however, with the limitations, I've changed my approach.

The UI extensions works good enough 🙂