I have a system that allows users to enter coupons (for example like dell or amazon)
I want to know how much a coupon has been used so after 500 times the coupon is no longer valid.
The way I am thinking right now is to insert the coupon into a table and then select count(*)
and if it reaches 50 then I don't insert and I return a message saying it's expired.
I think this solution works but I wanted to validate and maybe check if there's a better way to do it.
I assume you have coupons stored in some table with code, description, etc, etc. add num_used column to it and increment it every time the coupon is used. This way you can still insert the coupon into orders if need be but you don't need to do counts. You simply check how many times it was already used when you load your coupon info. I assume you check validity by coupon code anyway so throw another one in for number of times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With