I’m putting together an ecommerce site for a client with a fairly complex pricing scheme. I’ve chosen to use foxycart, and have all product prices dynamically come out of a database. The reason for this is that every customer gets different prices for products for single units, and for varying quantities purchased. I’m trying to build the most flexible system I can, but I’m not sure what is best.
firstly I’ll have a customer_table
with:
id, name, city, state, country, zip, phone
Next is where I’m trying to decide how to build things. Right now there are 18 or so unique products, and some of these come in different sizes/volumes and have unique price break points per product, per size. So one product would have a price for less than 4 purchased, another for less than 10, another for less than 19, and another for greater than 20, and difference prices for the same product but at a different size. These price break points are not standard across all products either. Some may have price breaks at 3,9,12, while others may have less than 5 and greater than 5. The best way can think is just to build a table with 50 columns listing all these out. None of the data repeats, since it will change depending on the cust_id, so it seems normalised to me, but I’m wondering what you all think. This table might look like this:
id, cust_id, product1_lt4, product1_lt20, product1_gt20, product2_lt6, product2_lt12, product2_lt60, product2_gt60, etc...
With lt and gt being less than/greater than obviously. It just gets so huge.
I was trying to break up the tables as much as possible having a Category_table, Sub Category_table, product_table, size_table, and price table but I can’t think of any good way of inputting the data without having loads of null fields or 50+ tables.
Let me know if this makes sense. I can provide more detail if needed. I guess my main question is, is it a bad idea to go with option 1?
I might go with something like this:
Then you can just assume that the lowest quantity associated with a product is for any amount less than, and the greatest quantity price is for any quantity over
I believe this would be the most flexible and scalable way to build something with the complexity that you are trying to achieve