CodeIgniter Forums

Full Version: Any good ideas for quantity discounts applied to cart items?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]skunkbad[/eluser]
I have been working on an e-commerce application for a customer, and they want to have quantity discounts for items. To make things easy, they limited the quantity discount to two levels (standard price and discounted price). I worked on this last night, and have something that appears to be working, but I'm not really satisfied with the way it was done. Ideally the discount would be part of the cart itself, and what I did involved some transformation of the cart within the controller/view.

So, I'd like to extend MY_Cart to achieve the following:

1) Calculate price based on the quantity, and whether or not a quantity discount applies for that quantity or even that item. Perhaps the tiered pricing would be stored in the item's options array. It could also be a new key altogether.
2) Modifies the item sub_total based on the current calculated price * qty
3) Cart total would obviously be updated as needed.
4) All other stock CI Cart methods not broken.

It's one thing to do it as I have done, but I'd like a clean solution, and one that allows for infinite (or reasonably infinite) qty discount levels.

Has anyone done this? This is my project for tonight, so any feedback is appreciated.