I'm developing a site which will sell products each of which can have 6 different options and each of these options has a cost involved so the final price is the cost of the product plus the cost of the options.
This works fine but now the client wants to have discounts on various products and options so for instance if a customer buys 3 products they get option 1 free.
To do this I have created a table of discounts which has a product code, a quantity and true/false fields for each of the six options discounts. If the order matches the product code quantity then whichever option(s) are set to true have their price set to zero.
This works well on simple discounts so I have defined discounts such as if you buy 3 products option 1 is free, if you buy 5 products then options 1 and 4 are free but the complication comes in that the client has a lot of either/or rules such as if you buy 5 of one product then you can have either option 1 free OR option 2 free.
Another one is if you buy 10 of a certain product you get option 2 free and either option 5 OR 6 free.
So my system works well with simple discounts but when there can be a large number of ANDs and ORs I'm not sure how best to handle it.
I could write some logic to handle each of these discounts but I'd rather define my discounts in a table so each additional discount doesn't require additional coding.
Any ideas guys?
Thanks.