Reply to Re: 2 dumb questions

Your name:

Reply:


Posted by Paul Furman on 03/03/07 07:09

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;}
}

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация