i have built a website and a developer friend of mine built a very simple paypal shopping cart for me.
http://www.fabricrehab.co.uk
there is a problem with the shopping cart, if a product is £3.70 and the quantity is 1, the total for that will show as £3.7 - not £3.70, if the product price is multiplied by 10, for example if the price for a single unit is £2.99 the the total will display as £29.9 - not £29.90.
here's the part of the include for the table row which displays the product that is in the cart, then takes the quantity in the text box multiplies this and displays it as the total.
foreach ($contents as $id=>$qty) {
$sql = 'SELECT * FROM products WHERE id = '.$id;
$result = $db->query($sql);
$row = $result->fetch();
extract($row);
$output[] = '<tr>';
$output[] = '<td width="45px"><img src="images/fabric/thumb/'.$thumb.'" width="45px" height="45px"></td>';
$output[] = '<td class="carttext" align="center"><a href="cart.php?action=delete&id='.$id.'" class="r"><img src="images/deletecart.gif" border="0"></a></td>';
$output[] = '<td class="carttext">'.$name.'</td>';
$output[] = '<td class="carttext">£'.$price.'</td>';
$output[] = '<td class="carttext" align="center"><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>';
$output[] = '<td class="carttext" align="right">£'.($price * $qty).'</td>';
$total += $price * $qty;
$output[] = '</tr>';
}
i do hope all that makes sense. i guess i just need a way of formatting the part '.($price * $qty).' with 2 decimal places at all times.
thanks in advance for your help and *fingers crossed* solutions.