December 20th, 2013, 04:41 AM
Litle help with pricing in cart
i have a e-shop and i have some quantitative offers for some products.
i want when the customers adds for example the quantity
1 to 4 to the cart, the price of 15 euros,
for 5 to 7 the price of 12 euros,
for 8 to 11 the price of 10 euros
and 12+ the price of 9 euros.
how is this possible? do you have any idea?
this is my SQL query
this quantities and prices are in another table named "quant_prices".
INSERT INTO cart (sessionid,prodID,qty,price VALUES ( '$sesid','$prodID','$qty','$price')
thanks in advance.
December 20th, 2013, 04:51 AM
Then we need to see that table.
Originally Posted by Kyriakos
December 20th, 2013, 04:55 AM
the quant_prices table is the table in the image above. it has 3 colums (prodID, qty, price)
Originally Posted by Jacques1
December 20th, 2013, 05:09 AM
So the "other table" is in fact this one?
Simply fetch the row with the biggest quantity not exceeding the quantity selected by the customer:
ID = ...
AND Quantity <= ...
Given the ID and Quantity, you can now uniquely identify the price (assuming your primary keys are set up correctly).
It might be a good idea to rename that "ID" column into something sensible like "product_id". Otherwise, everybody will think this is an AUTO_INCREMENT column.