Page 1 of 1

PHP for pricing items

Posted: Sun Nov 19, 2006 1:22 am
by peroberg
Dear All
I am used to VB programming and HTML etc.
But PHP is quite new for me.
Now I am working with an Online E-shop that also uses PHP.
What I want to do is to set prices so that if someone buy extra many pcs of the same item he gets a reduction in price per item.

Any suggestions. Will be moste pleased for the same.
Per

Posted: Sun Nov 19, 2006 1:29 am
by feyd
A database, or some other similar media to store information you can use for this pricing structure is really all that's needed. Likely, this would involve at least two tables. One table for the basic information on the product (sans price), and another that refers to the former table and has a price field and some scaling information (or maybe a quantity requirement).

Surprising answer

Posted: Sun Nov 19, 2006 10:53 pm
by peroberg
Your reply is MOST SURPRISING!!!
I have been a member of a number of forums and often given help to other developers etc – and that free of cost. As I am NOT asking for the development of a full site but only one or two lines I had expected a friendly answer. What else is this forum for?
I know that I Visual Basic I would have typed:
If quantity is > 100 then price = price * 0.9
Or something like that. A single line. Not anything you pay hundreds of dollars for.
Per

Posted: Sun Nov 19, 2006 11:35 pm
by mickd
peroberg wrote:Your reply is MOST SURPRISING!!!
I have been a member of a number of forums and often given help to other developers etc – and that free of cost. As I am NOT asking for the development of a full site but only one or two lines I had expected a friendly answer. What else is this forum for?
I know that I Visual Basic I would have typed:
If quantity is > 100 then price = price * 0.9
Or something like that. A single line. Not anything you pay hundreds of dollars for.
Per
feyd wrote:A database, or some other similar media to store information you can use for this pricing structure is really all that's needed. Likely, this would involve at least two tables. One table for the basic information on the product (sans price), and another that refers to the former table and has a price field and some scaling information (or maybe a quantity requirement).
Hmm, did i miss something?

In PHP, according to your VB code, it would be very similar.

Code: Select all

if($quantity > 100) {

$price = $price * 0.9;
// $price *= 0.9; (would do the same thing as above)

}

Posted: Mon Nov 20, 2006 2:40 pm
by feyd
In all of the ecommerce type systems I've worked on, the volume pricing was rarely a simple multiplier. The solution I discussed previously can include multipliers, it all depends on how your write and read the data stored.