function showCart($cart) { sort($cart); $total = 0.0; //decimal $count = 0; $discount = 0; $output = "<h2>winkelwagen</h2>"; $output .= "<table border=1><tr><th>pizza (size)</th><th>aantal</th><th>prijs</th><th>korting</th></tr>"; for ($i = 0; $i < count($cart); $i++) { $output .= "<tr>"; $output .= "<td>" . $cart[$i][0] . " (" . $cart[$i][1] . ")</td>"; //naam en size $output .= "<td>" . $cart[$i][2] . "</td>"; //aantal summized $output .= "<td>" . $cart[$i][3] . "</td>"; //prijs per aantal pizza en size $prijsperstuk = $cart[$i][3] / $cart[$i][2]; //prijs per stuk weer even terugrekenen $discountperorder = calcDiscount($prijsperstuk, $cart[$i][2]); //korting berekenen $output .= "<td>" . $discountperorder . "</td>"; //korting $output .= "</tr>"; $count += $cart[$i][2]; //subtotaal aantal pizzas $total += $cart[$i][3]; //subtotaal prijs $discount += $discountperorder; //subtotaal korting } $output .= "<tr>"; $output .= "<td>totaal:</td>" . "<td>{$count}</td>" . "<td>€ " . ($total - $discount) . "</td>"; //totaal aantal pizzas $output .= "</tr>"; $output .= "<tr>"; $output .= "<td><form method='post'>"; $output .= "<input type='submit' name='afrekenen' value='afrekenen'>"; $output .= "<input type='submit' name='emptycart' value='Winkel wagen Legen'>"; $output .= "</form></td>"; $output .= "</tr>"; $output .= "</table>"; $output .= "</center></div>"; return $output; }
try { $validity = $db->loadResult(); } catch (Exception $e) { } $validity = new DateTime($validity, new DateTimeZone('Europe/Berlin')); } $validity->add(new DateInterval('P1Y')); $subscription->valid = $validity->format('Y-m-d H:i:s'); $subscription->net = $netAmount; $subscription->vat = $vat; $subscription->rate = $rate; $subscription->total = number_format($netAmount + $vat, 2); // Compute discount if necessary if ($subscription->discount) { require_once 'discount.php'; $subscription = calcDiscount($subscription); } // Set the appropriate article for redirection switch ($level[0]) { case '1': if ($subscription->paymentMethodId[0] == 1) { $subscription->content = 11; $subscription->menuitem = 169; } else { $subscription->content = 16; $subscription->menuitem = 202; } break; case '2': if ($subscription->paymentMethodId[0] == 1) { $subscription->content = 14;
break; case "r": return "senior"; break; } } if (isset($_POST['formSubmit'])) { // Write a statement to fetch the value for level from $_POST. $level = $_POST['level']; // Write a statement to fetch the value for price from $_POST. $price = $_POST['price']; if (empty($price)) { echo "<p>You must enter the price!</p>\n"; } else { // Call the function, calcDiscount with price and level as arguments. $finalPrice = calcDiscount($price, $level); // Call the function, getLevelString with level as argument. $studentLevel = getLevelString($level); echo "<p>"; echo "Since you are a {$studentLevel} your final price is {$finalPrice}<br/>"; echo "</p>"; } } ?> <form id="form1" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?> " method="post"> <label for='price'>Enter Book Price:</label><br/> <input type="text" name="price" id="price" maxlength="10" /> <br/><br/>