Search the Community
Showing results for tags 'php checkout'.
-
Okay here's the problem, I've got my code typed up and everything seems to be working. However this comes up: Notice: Undefined variable: storeID in \\Chapter 10\ReinforcementExercises\class_OnlineStores.php on line 101 first of all the variable has alread been defined in the class definition. Secondly, I'm having more items being added to the shopping cart when the checkout link is clicked. checkout function public function checkout() { $ProductsOrdered = 0; foreach($this->shoppingCart as $productID => $quantity) { if ($quantity > 0) { ++$ProductsOrdered; $SQLstring = "INSERT INTO orders " . " (orderID, prductID, quantity) " . " VALUES('" . session_id() ."', " . "'$productID', $quantity)"; $QueryResult = $this->DBConnect->query($SQLstring); } } echo "<p><strong>Your order has been " . "recorded.</strong></p>\n"; } and the getProductList function public function getProductList() { $retval = FALSE; $subtotal = 0; if (count($this->inventory) > 0) { echo "<table width='100%'>\n"; echo "<tr><th>Product</th><th>Description</th>" . "<th>Price Each</th><th># in Cart</th>" . "<th>Total Price</th><th> </th></tr>\n"; foreach ($this->inventory as $ID => $Info) { echo "<tr><td>" . htmlentities($Info['name']) . "</td>\n"; echo "<td>" . htmlentities($Info['description']) . "</td>\n"; printf("<td class='currency'>$%.2f</td>\n", $Info['price']); echo "<td class='currency'>" . $this->shoppingCart[$ID] . "</td>\n"; printf("<td class='currency'>$%.2f </td>\n", $Info['price'] * $this->shoppingCart[$ID]); echo "<td><a href='" . $_SERVER['SCRIPT_NAME'] . "?PHPSESSID=" . session_id() . "&ItemToAdd=$ID'>Add " . " Item</a><br />\n"; echo "<a href='" . $_SERVER['SCRIPT_NAME'] . "?PHPSESSID=" . session_id() . "&ItemToRemove=$ID'>Remove " . " Item</a></td>\n"; $subtotal += ($Info['price'] * $this->shoppingCart[$ID]); } echo "<tr><td colspan='4'>Subtotal</td>\n"; printf("<td class='currency'>$%.2f</td>\n", $subtotal); echo "<td><a href='" . $_SERVER['SCRIPT_NAME'] . "?PHPSESSID=" . session_id() . "&EmptyCart=TRUE'>Empty " . " Cart</a></td></tr>\n"; echo "</table>"; echo "<p><a href=' 'Checkout.php?PHPSESSID='" . session_id() . "&CheckOut=$storeID'>Checkout</a></p>\n"; - this is where the error is being indicated. $retval = TRUE; } return($retval); } I'd appreciate any help anyone can provide...