1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| echo "<p>Order processed at ".date('H:i, jS F Y')."</p>";
echo "<p>Your order is as follows: </p>";
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
if ($totalqty < 1) {
echo '<p style="color:red">';
echo "Please order at least one item from the list!</br>";
echo '</p>';
} else {
echo "Items ordered: ".$totalqty."<br />";
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;
echo "Subtotal: $".number_format($totalamount,2)."<br />";
$taxrate = 0.10; // local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
echo "Total including tax: $".number_format($totalamount,2)."<br />";
}
if ($tireqty < 10) {
$discount = 0; // No discount
} elseif (($tireqty >= 11) && ($tireqty <= 49)) {
$discount = 0.05; // Discount of 5%
} elseif (($tireqty >= 50) && ($tireqty <= 99)) {
$discount = 0.10; // Discount of 10%
} elseif ($tireqty >= 100) {
$discount = 0.15; // Discout of 15%
}
$totalamount = $totalamount * (1 - $discount);
echo "The total amount with your discount is $".number_format($totalamount,2)."<br />"; |