Remove invalid discounts just before checkout.

m_quinteiro
Shopify Partner
6 0 0

I want to apply some validation rules to a discount just before payment. 

 

Is there a webhook, or another, way to say to checkout if a discount for that client is ok or not?

 

The rule is very simply. Only clients without previous orders can use the discount (the only once per user is not valid for me). I can remove the discount in early steps but I'm out of control during the checkout.

 

I thought to remove on the checkout webhook create/update event but could be unfair to the customer to show a different prices in the checkout out and payment steps.

 

Replies 2 (2)

ShopifyDevSup
Shopify Staff
1367 228 479

Hi @m_quinteiro👋

 

One method to remove discount codes would be to use the `cartDiscountCodesUpdate` mutation

 

Hope that helps!

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

m_quinteiro
Shopify Partner
6 0 0

Hi @ShopifyDevSup the problem is not how, the problem is when.

 

In the 1st step of the checkout, your side checks your rules and remove invalid coupons with a beauty mensaje.

 

The perfect behavior is that your engine calls tu one shop service that approvals the order or the coupons or a peace of code or liquid template to insert code in your first step.