Click to See Complete Forum and Search --> : PHP to make a "Shopping Cart"?


ajs
11-18-2003, 11:21 PM
Hello Everyone,

I am the new guy.

Anyways, thanks for having me! Can anyone tell me how to build my own shopping cart. All I need to know is how to use an addition and subtraction code for adding product amounts together, then adding tax too, if applicable.

Any help would be great!

Thanks,

Aaron
This is my business website; www.thunderbirdconcepts.com
This site I made, is super plain, due to keeping it just for a business purpose. If it were a graphic design site, then it would be a little fancier.

pyro
11-19-2003, 08:08 AM
Adding and subtracting is done the same as other programming languages, the +/- operators.

Take a look at this simple example:

<?PHP
# item's prices
$item1 = "10";
$item2 = "15.95";

# get the sub-total
$subtotal = $item1 + $item2;

# add tax and shipping:
$tax = ".055";
$shipping = "4.95";

$total = $subtotal + $subtotal*$tax + $shipping;


# print out the total (and round to 2 decimal places)
echo "Total: $".round($total, 2);
?>

ajs
11-19-2003, 09:14 AM
Nice!

So is PHP supported by all browsers OK? I noticed you say that the -/+ operators can done with other programming languages, what is the best programming language to use? Is it PHP?

Thank you in advance for any suggesstions,
Aaron
:)

pyro
11-19-2003, 10:07 AM
Since PHP runs on the server (as do all server-side languages) it/they are not browser dependent. They will run correctly regardless of the browser used. As far as if PHP is the "best programming language to use", it depends who you ask... ;) I'm most framilar/comfortable with PHP, so that would certainly be my choice. It is also probably one of the most widly supported server-side languages, as far as servers go.