Page 1 of 1

Shopping cart will not display shipping in right format

Posted: Mon Nov 17, 2003 7:53 pm
by mony
:( Shopping cart will not display cost in the right format: pls help.
check it out at http://www.whiteliesdarktruth.com/purchase2.php

It displays 24.95
Shipping 3.60
Total Cost 28.55

the right display should be:

24.95
3.60
28.55

here is the code:

<table>
<tr>
<td width="250"><font color="#FfFfFf"><b>Product Name</b></font></td>
<td width="100"><font color="#FfFfFf"><b>Price</b></font></td>
<td width="100"><font color="#FfFfFf"><b>Qty</b></font></td>
<td width="100"><font color="#FfFfFf"><b>Total</b></font></td>
</tr>
<tr>
<td><font color="#FfFfFf">White Lies Dark Truth (Hardcover) </font></td>
<td><font color="#FfFfFf"><?php echo $bookPrice ?></font></td>
<td><font color="#FfFfFf"><?php echo $numBooks ?></font></td>
<td><font color="#FfFfFf"><?php echo $bookPrice*$numBooks ?></font></td>
</tr>
<tr>
<td></td>
<td></td>
<td ><font color="#FfFfFf"><b>Shipping</b></font></td>
<td><font color="#FfFfFf"><?php echo $arrShippingCost[$shippingIndexSelected] + $extraShipping*($numBooks-1); ?></font></td>
</tr>
<tr>
<td></td>
<td></td>
<td><font color="#FfFfFf"><b>Bill Total</b></font></td>
<td><font color="#FfFfFf"><?php echo $totalCost ?></font></td>
</tr>
</table>

Posted: Mon Nov 17, 2003 8:30 pm
by Paddy
Firstly that link doesn't work. Secondly would you be a little more specific as to what you want. And welcome to the forums. :)

Follow Up

Posted: Mon Nov 17, 2003 8:43 pm
by mony
Sorry for the mess up here is the right link:
http://www.monysingh.com/orders/purchase2.php

I want the shipping price to be displayed in the right format
at the moment it is showing up out of place.

Posted: Mon Nov 17, 2003 8:55 pm
by Paddy
The alignment looked fine via my browser. You may want to use this echo though to give you a trailing zero.

echo(number_format($totalcost, 2, '.', ''));

And the same for the rest of the dollar values. If you would like to read more on that go here.

http://au2.php.net/manual/en/function.number-format.php

Posted: Mon Nov 17, 2003 9:01 pm
by Weirdan
Or you can use [php_man]printf[/php_man] function. Btw there are example on currency formatting.