I have a rather complex shopping cart system which needs
to be able to figure out a lot of things about the prices
of the items in a user's cart. I need the system to
updatable by somebody that knows less about the system than
me. I think that the best way to do this is if I could
provide a configuation system that encodes a series of
rules about the system in a document that is
seperate from the actual program. Here are
some examples of the kinds of things I want to encode:
- Widgets cost $250
- Gizmos cost $125
- All customers that have had at least three orders from
us in the past get a 20% discount.
- Buy 3 Widgets and we'll throw in a Gizmo for free.
- Certain classes of customers get 50% off. (This is
applied before the 20% discount)
- Buy at least 10 Gizmos, and we'll reduce the cost by
$30 per unit (This applies after the 50% discount if they get it,
but before the 20% discount if they get that).
- If you buy the service agreement that goes along with
the Widgets during this month, we'll sell you the first
year of the agreement for free when you sign up for at
least a three year agreement.
This seems to me like it could become very confusing,
and very ad-hoc in a short period of time. I really
hate to re-invent the wheel on this sort of thing (especially
when it is a very large wheel). I was wondering
if there were any formats that people have already
come up with for defining rules in systems like these?
I looked through CPAN, but nothing really jumped out at
Thanks in advance for any pointers.