Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Discount Script applies discounts even if underlying code is rejected

Discount Script applies discounts even if underlying code is rejected

Ryoshin
Shopify Partner
40 3 7

I have this line at the top of my code:

 

if Input.cart.discount_code&.code == "CYBER2023" && !Input.cart.discount_code&.rejected?

However, if the code is rejected (like it has a minimum of $100 and the cart is $50), it rejects the code but applies everything that comes after the if statement above.

So, I have 2 questions:

- How can I make scripts not work if the code is not applied? (In production it simply passes that the code is not rejected even if it is)
- If that's not possible, how do I implement features like the discount only being used once per customer?

Replies 0 (0)