I’m creating a coupon system with many different types of coupons. I’d like to structure it so it can be extended. I’m not sure the best way to store the different types of coupons, for example:
- Fixed amount off entire order
- Fixed precentage off entire order
- Fixed amount off one item (could be by sku of item or could be most expensive item)
- Fixed percent off one item (could be by sku of item or could be most expensive item)
- Buy x get y
- Free product (by sku of item, by price)
- x for $y (3 for $2, 10 for $15, etc.)
I’m using mysql, would it best to store as an array? json? Any other ideas or people with similar issues care to share how they did it?
I would create another table – tblCouponType for instance and populate it with a unique numerical and string for notes of the types I have, and add to it as new types become available. Then add another column to your coupon table that references the numerical value of your coupon type. This helps with the whole -“Relational” part of the database:)