include("../config.inc.php"); include("../menu1.inc.php"); include("../sidebar.inc.php"); $sidecatlink = "none"; $sidestorelink = "yes"; $_SESSION['ref'] = "$sslbase/store/"; $_SESSION['pageref'] = "store"; $oops = rtrim($_SESSION['oops']); $total = "0"; $billname = rtrim($billname); $shipname = rtrim($shipname); if(isset($_COOKIE['ID_my_site'])) { include("../auth.inc.php"); } else { $guest = 1; } //this checks for guest if ($guest == 1) { if ($billname == '') { $username = ''; } } else { if ($pass != $realpass AND $pass != $realtoken) { header("Location: ../guest/"); } else { $passstatus = "okay"; } } //END checks for guest //otherwise they are shown the admin area if ($passstatus == "okay" OR $guest == 1) { $cart = $_COOKIE['cart']; $cart = unserialize($cart); if (isset($_POST['add'])) { $item = $_POST['item']; $quantity = $_POST['quantity']; $quanquery = mysqli_query($conn,"SELECT quan FROM store_items WHERE id = '$item'"); while ($rowq = $quanquery->fetch_assoc()) { $quantest = $rowq['quan']; } if (is_array($cart)) { $cartnum = count($cart); } else { $cartnum = 0; } $added = 0; if ($cartnum > 0) { $cartkeys = array_keys($cart); sort($cartkeys); $j = 0; while ($j < $cartnum) { $key = $cartkeys[$j]; $typequery = mysqli_query($conn,"SELECT type FROM store_items WHERE id = $item"); while ($rowt = $typequery->fetch_assoc()) { $type = $rowt['type']; } if ($key == $item AND $type != 'pot') { $oldquan = $cart[$key]; $newquan = $oldquan + $quantity; if ($newquan > $quantest) { $newquan = $quantest; } if ($quantest > 0) { $cart[$key] = "$newquan"; $added = 1; } else { unset($cart[$key]); } } $j++; } if ($added != 1) { $cart[$item] = $quantity; } } else { if ($quantest > 0) { if ($quantity > $quantest) { $quantity = $quantest; } $cart[$item] = $quantity; } } $crt = serialize($cart); $hour = time() + 60*60*24*10; setcookie(cart, $crt, $hour, '/'); //if (isset($_POST['add'])) { } if (isset($_POST['submit'])) { if (is_array($cart)) { $cartnum = count($cart); } else { $cartnum = 0; } if ($cartnum > 0) { $cartkeys = array_keys($cart); sort($cartkeys); $j = 0; while ($j < $cartnum) { $key = $cartkeys[$j]; $delete = $_POST['item_delete_'.$key]; if ($delete == 1) { unset($cart[$key]); } else { $newquan = $_POST['item_quantity_'.$key]; $quanquery2 = mysqli_query($conn,"SELECT quan FROM store_items WHERE id = '$key'"); while ($rowq2 = $quanquery2->fetch_assoc()) { $quantest = $rowq2['quan']; } if ($newquan == 0 OR $quantest < 1) { unset($cart[$key]); } else { if ($newquan > $quantest) { $newquan = $quantest; } $cart[$key] = $newquan; } } $j++; } $crt = serialize($cart); $hour = time() + 60*60*24*10; setcookie(cart, $crt, $hour, '/'); //if ($cartnum > 0) { } //if (isset($_POST['submit'])) { } if (is_array($cart)) { $cartnum = count($cart); } else { $cartnum = 0; } if ($cartnum > 0) { $cartkeys = array_keys($cart); sort($cartkeys); $j = 0; while ($j < $cartnum) { $key = $cartkeys[$j]; $orderquery = mysqli_query($conn,"SELECT price,ship FROM store_items WHERE id ='$key'"); while ($rowo = $orderquery->fetch_assoc()) { $price = $rowo['price']; $ship = $rowo['ship']; } if ($ship == "Y") { $shipquery = mysqli_query($conn,"SELECT price FROM store_shipping WHERE id = '1'"); while ($rows = $shipquery->fetch_assoc()) { $newshipprice = $rows['price']; } $shipprice = $shipprice + $newshipprice; } $sub = ($cart[$key] * $price); $total = $total + $sub; $shipprice = number_format($shipprice,2,'.',''); $total = number_format($total,2,'.',''); $j++; } } setcookie(total, $total, $hour, '/'); setcookie(shipprice, $shipprice, $hour, '/'); $total = ''; $sub = ''; $shipprice = ''; ?>
$firstname $lastname
$city, $state
6% MD Sales Tax: $$tax
"; $grandtotal = $grandtotal + $tax; } if ($state == "PA") { $tax = $total * .06; $tax = number_format($tax,2,'.',''); //echo "6% PA Sales Tax: $$tax
"; $grandtotal = $grandtotal + $tax; } $grandtotal = number_format($grandtotal,2,'.',''); //THIS makes $guest = 0 just to reset everything if we come back to this page as a logged-in person; not positive that this is needed--haven't tested it $guest = 0; } echo "