I’m racking my brain trying to figure out a good method for a coupon
system for our ecommerce site. Basically We have a variety of
consditions for certain coupons and a variety of effects.
Some examples:
- 5% off any order
- Free shipping on orders over $50
- Free shipping on an order if a product foo is part of the order
- 10% off product foo
- 5% off entire order if product foo is in the order
So I need to somehow store the properties of a coupon, and validate that
all its conditions are met, and then apply a couple different effects.
I’m a bit baffled about where to go next. I thought of creating a Proc
for conditions and serializing it in the DB, but that makes it hard to
define via an interface and is just plain messy.
Any ideas on how to approach this type of polymorphic complexity?