You are here: 2 dumb questions « PHP Programming Language « IT news, forums, messages
2 dumb questions

Posted by Paul Furman on 03/02/07 23:30

First, I'm sure the following code is not using an efficient structure
for the nested if then else's but I can't recall the right way:

if ($item_qty > 19)
{
$price = ($price * .925);
$qty_discount = '20 @ 7.5%';
} else
{
if ($item_qty > 9)
{
$price = ($price * .95);
$qty_discount = '10 @ 5%';
} else
{
if ($item_qty > 4)
{
$price = ($price * .975);
$qty_discount = '5 @ 2.5%';
}
}
}

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.

hmmm... maybe for that one, since 50% * 2 is 100 then:

$item_qty = 100
$price = $100

$qty_discount = ($item_qty/2)
[50(%)]


$price = ($price - ($price * ($qty_discount / 100)))
[$50] $100 - $100 * 50%

Um, damn, I'm lost...

 

Navigation:

[Reply to this 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

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