Hi.
I'm trying to use number_format to get the proper number of decimals, but I'm getting confusing results. Here's the bit of code...
//calculate price...
$stickertotal=($numofstkrs * 19.95);
number_format($stickertotal, 2, '.', ',');
$beforeshipping=($activatefor * $stickertotal);
number_format($beforeshipping, 2, '.', ',');
if ($shipcharge==1){$shipping=4.95;}
if ($shipcharge==0){$shipping=0.00;}
$aftershipping=($beforeshipping+$shipping);
number_format($aftershipping, 2, '.', ',');
echo"
stickertotal: $stickertotal <br>
beforeshipping: $beforeshipping <br>
shipping: $shipping <br>
aftershipping: $aftershipping <br>
";
When I calculate with $numofstkrs=1 and $activatefor=1, I get this...
stickertotal: 19.95
beforeshipping: 19.95
shipping: 4.95
aftershipping: 24.9 <<<This is the problem and gets rejected by my cc processor
When I calculate with $numofstkrs=2 and $activatefor=1, I get this...
stickertotal: 39.9 <<<Here
beforeshipping: 39.9 <<<and here...
shipping: 4.95
aftershipping: 44.85
I'm thinking number_format isn't working at all and it only shows 2 decimals when it works out that there's a second one to show.
If you could pass along your knowledge, it would be greatly appreciated.