Paul Furman wrote:

>Second question, if you see what I'm doing it's to discount e-commerce

sales based on the quanity ordered. It's easier to pull 50 of the same

item than 1 each of 50 different things. I'm not sure what's quite

right but lets say an order of 1 has no discount and an order of 100

is 50% off. Surely there is a way of incrementally calculating the

discount for any quantity between 1 and 100 but I'm no math whiz.

I solved this part..

This is a little better:

$price = $r["price"] / 100;

$full_price = $price / 100;//reserve for calculating discounts

$item_qty = $row["item_qty"];

//quantity discount

$limit = 50;//no further discount above this qty

$max_disc = .3;//max discount

$rate = ($max_disc/$limit);//discount per unit above 1

//subtract one 'rate' so a purchase of 1 unit is not discounted

($qty_discount = (($item_qty*$rate)/1));

//set cap

if ($item_qty ($limit-1)){$qty_discount = $max_disc;}

//subtract qty discount from price

$price = ($price - ($price * ($qty_discount)));

then:

//buyer discount

if ($discount != 0){//if any buyer discount

if (($discount-($qty_discount*100))>0){//if not already discounted

above qty disc

//reduce buyer discount by amount of quantity disc

$adj_discount = ($discount-($qty_discount*100));

$price = ($price - ($full_price * ($adj_discount / 100)));

} else {$adj_discount = 0;}

}