How to include product specific discounts to my current cart..??
I've got some discounts already setup and working great in my eCart (you guys helped me with that awhile back, actually).
My database stores the discount code data and I have session vars for DiscountCode, DiscountType, and DiscountAmount.
Then I have 2 separate discount rules setup in eCart: one for the flat rate type and another for percentage based type. The flat rate rule just uses the flat rate amount set in the DiscountAmount session. The percentage rule takes the DiscountAmount times the cart's subtotal.
I'd like to add the ability to include discount codes in my system that only apply to certain items. For example, if we're going to do a special on one product we don't want people getting 10% off everything in their cart...just that one line item. We have plenty of codes that do pertain to an entire card, though, so I need both to function.
This probably isn't the best way to do this, but I added a single field into my discount codes db table called product_ids. I'm simply adding the ID's of any products I want this coupon to work for separated by commas. Then I have those available in my "apply discounts" script so I can loop through them and handle it accordingly.
I just don't want to get too far with that and figure out I should do it an entirely different way. Should I go with a separate table that just stores related products to discount codes, or can I work with what I'm doing here?
Either way, some advice on the best plan of attack would be greatly appreciated. Thanks!!!