NEW TICKET#19 · Checkout
Coupon: percent or fixed, capped, never below zero
Lena Fischer · Finance & Ops
Opened today
“A customer put a $15 coupon on a $10 add-on, and the invoice said we owe them $5.00. A total can never go below zero. While you're in there: our percent coupons are sold as "20% off, up to $50", and that cap (maxOff) isn't applied at all, so a $400 order got $80 off. And a percentage should round to the nearest cent; we're sending invoices with $149.85 discounts on $999 orders. Can you fix applyCoupon?”
YOUR PLAN
- 1Watch an example2 min
- 2Warm-up 11 min
- 3Warm-up 21 min
- 4Fix the ticket11 min
BY THE END YOU CAN
- Keep a number from going below zero with Math.max
- Cap a number with Math.min
- Round money to whole cents at the right moment