Forum Moderators: coopster
[2]Shipping: <?php if ($total > 81.75) {printf ("%01.2f", $total * .11);}else {echo "8.99 ";}?>[/2] but I need to add another calculation, IF the order is from a country other that the U.S. - something like,
if ($country is NOT USA, * .25)
I still need the other two parts to work the same as they have been, but need to multiply $total by 25% if outside of the US...
so, in non-php terms... IF $country is USA, AND $total > 81.75, printf $total * .11,
but IF $ country is NOT USA, printf $total * .25
Don't know how to write multiple IFs...
Any/all help appreciated...
thanks in advance.
mc
if ($total>81.75) {
$final=$total*1.11;
} else {
$final=8.99;
}if ($country!="USA") {
$final=$final*1.25;
}
printf ("%01.2f",$final);
It's not that complicated.. :)
Are you doing this for a client or is this your online store?
If you are developing this I'd suggest moving the 8.99 and 81.75 to variables that you include from a config.php since the users may want to change these without hunting for them in the main script.
if ($total>81.75) {
$shipping=$total*.11;
} else {
$shipping=8.99;
}if ($country!="USA") {
$shipping=$total*1.25;
}
$total=$total+$shipping;
printf ("%01.2f",$total);
I'd advise against passing it to the next page as hidden post fields, it's quite easy to fake the value. Next thing you know you'd be accepting $0.50 orders for stuff worth $500... keep track of the numbers serverside.