Here is my DB query loop. What I want to do is calculate the total delivery price for the order. The trouble is each product has a cut off point where the total price of that product once met will no longer add more but only for that product.
Forget the quantities they order at present, if they had 2 rows with the same productid and another product with another id. The first item can’t cross a certan threadhold for delivery. Once it does, it stays at that threshold price and then the postage of the next iem is added.
[code=php] require(‘inc_dbconnect.php’);
$currentquery = “select * from cart, items, products
where cart.Cart_ID = ‘”.$cartid.”‘
AND items.Cart_ID = cart.Cart_ID
AND items.Product_ID = products.Product_ID
Order by products.Product_ID asc”;
$result = mysql_query($currentquery);
$num_results = mysql_num_rows($result);
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
$dbitemprice = stripslashes($row[‘Item_Price’]);
$cur_productid = stripslashes($row[‘Product_ID’]);
$pricedel = stripslashes($row[‘Product_DeliveryPrice’]);
$cap = stripslashes($row[‘Product_DeliveryCap’]);
$post_total = $post_total + $pricedel;
}