diff --git a/admin/login.php b/admin/login.php index 41be8d6..f3565b9 100644 --- a/admin/login.php +++ b/admin/login.php @@ -81,7 +81,7 @@ if ($_SESSION["isLoggedIn"] == true and $_SESSION["user_type"] == "admin"){ -
+
diff --git a/admin/login_action_admin.php b/admin/login_action_admin.php new file mode 100644 index 0000000..b916649 --- /dev/null +++ b/admin/login_action_admin.php @@ -0,0 +1,41 @@ + 0) { + $_SESSION["isCustomer"] = true; + } + $result = vendorExists($_SESSION["email"]); + if ($result > 0) { + $_SESSION["isVendor"] = true; + } + header("location: index.php"); + } else { + // $_SESSION["loginError"] = "Invalid email or password. Please try again."; + header("location: login.php?error=1"); + } + + + // $_SESSION["token"] = $result; + // $result = profile($_SESSION["token"]); + // $_SESSION["userId"] = $result["profile"]["userId"]; + // $result = customerExists($_SESSION["email"]); + // if($result>0){ + // $_SESSION["isCustomer"] = true; + // } + // $result = vendorExists($_SESSION["email"]); + // if($result>0){ + // $_SESSION["isVendor"] = true; + // } + // header("location: $url") +?> \ No newline at end of file diff --git a/admin/token-renew.php b/admin/token-renew.php new file mode 100644 index 0000000..104fa25 --- /dev/null +++ b/admin/token-renew.php @@ -0,0 +1,11 @@ + diff --git a/admin/vendor-profile.php b/admin/vendor-profile.php index 5e07d7e..11acc9f 100644 --- a/admin/vendor-profile.php +++ b/admin/vendor-profile.php @@ -65,21 +65,20 @@ foreach ($vendorPayouts as $payout) { } } -$token = $_SESSION["token"]; +if (isset($_SESSION["token"])) { + $token = $_SESSION["token"]; + $token_parts = explode(".", $token); + $token_payload = base64_decode($token_parts[1]); + $token_data = json_decode($token_payload); -$token_parts = explode(".", $token); -$token_payload = base64_decode($token_parts[1]); -$token_data = json_decode($token_payload); + $issued_at_time = $token_data->iat; + $expiration_time = $token_data->exp; + $renewal_time = $issued_at_time + 3300; -$expiration_time = $token_data->exp; -$issued_at_time = $token_data->iat; - -$renewal_time = $issued_at_time + 3300; - - -if (time() >= $renewal_time) { - $token = loginRenew($_SESSION["email"], $_SESSION["password"], $token); - $_SESSION["token"] = $token; + if (time() >= $renewal_time || time() >= $expiration_time) { + header("Location: token-renew.php"); + exit; + } } // $token = loginRenew($_SESSION["email"], $_SESSION["password"], $token); // $_SESSION["token"] = $token; @@ -115,6 +114,23 @@ if (time() >= $renewal_time) { + diff --git a/login_action.php b/login_action.php index adb9c4e..0530f51 100644 --- a/login_action.php +++ b/login_action.php @@ -19,7 +19,7 @@ if ($result > 0) { $_SESSION["isVendor"] = true; } - header("location: $url"); + header("location: index.php"); } else { // $_SESSION["loginError"] = "Invalid email or password. Please try again."; header("location: login.php?error=1"); diff --git a/product-left-sidebar.php b/product-left-sidebar.php index ca03584..2484b5d 100644 --- a/product-left-sidebar.php +++ b/product-left-sidebar.php @@ -215,7 +215,8 @@ if (isset($_GET['id'])) { right: 15px; bottom: 0; border-radius: 0 0 10px 10px; - } + } + /* 02-21-2024 Stacy added css for addtocart & wishlist */ @@ -276,17 +277,17 @@ if (isset($_GET['id'])) {
'; - echo $_SESSION["SuccessfullySent"]; - echo '
'; - unset($_SESSION["SuccessfullySent"]); - echo " "; - } + } ?>
@@ -325,7 +326,8 @@ if (isset($_GET['id'])) { $productImage = $i; } ?> - +
@@ -378,16 +380,16 @@ if (isset($_GET['id'])) {
As low as 0) { - echo '' . $product_details['regular_price'] . ''; - echo '' . $product_details['sale_price'] . ''; - } elseif (!isset($product_details['regular_price']) || $product_details['regular_price'] <= 0) { - echo 'Contact Seller for Price'; - } else { - echo '' . $product_details['regular_price'] . ''; - } - // 02-13-24 Jun Jihad Removed Logic to DIsplay Price Range of Variable Products + // 02-13-24 Jun Jihad Removed Logic to DIsplay Price Range of Variable Products + if (isset($product_details['sale_price']) && $product_details['sale_price'] > 0) { + echo '' . $product_details['regular_price'] . ''; + echo '' . $product_details['sale_price'] . ''; + } elseif (!isset($product_details['regular_price']) || $product_details['regular_price'] <= 0) { + echo 'Contact Seller for Price'; + } else { + echo '' . $product_details['regular_price'] . ''; + } + // 02-13-24 Jun Jihad Removed Logic to DIsplay Price Range of Variable Products ?>
@@ -396,7 +398,7 @@ if (isset($_GET['id'])) {
- + @@ -405,7 +407,7 @@ if (isset($_GET['id'])) { VARIATION
@@ -594,10 +597,10 @@ if (isset($_GET['id'])) { - '/> + ' /> " id="qty-input" min="" /> - '/> + ' /> `; - document.getElementById(`qty-input-${response.items[0]._id}`).value = updatedQuantity; - } else { - // If the cart item doesn't exist, create a new one - console.log("Error updating order:", updateOrderXhr.responseText); - } + document.getElementById(`qty-input-${response.items[0]._id}`).value = updatedQuantity; + } else { + // If the cart item doesn't exist, create a new one + console.log("Error updating order:", updateOrderXhr.responseText); + } - getLatestOrders(); - updateCartItemCount(); - document.getElementById("addToCartMessage").innerText = "Product added to cart!"; - setTimeout(function() { - document.getElementById("addToCartMessage").innerText = ""; - }, 1000); - } else { - // Handle error response from the server - console.log("Error response from the server"); - console.log(xhr.responseText); // Log the server's response - } - } - }; - var existingQuantity = parseInt(existingOrder.items[0].quantity, 10); - var newQuantity = parseInt(quantityValue, 10); - var updatedQuantity = existingQuantity + newQuantity; + getLatestOrders(); + updateCartItemCount(); + document.getElementById("addToCartMessage").innerText = "Product added to cart!"; + setTimeout(function() { + document.getElementById("addToCartMessage").innerText = ""; + }, 1000); + } else { + // Handle error response from the server + console.log("Error response from the server"); + console.log(xhr.responseText); // Log the server's response + } + } + }; + var existingQuantity = parseInt(existingOrder.items[0].quantity, 10); + var newQuantity = parseInt(quantityValue, 10); + var updatedQuantity = existingQuantity + newQuantity; - // Check if the updated quantity exceeds the previous price matrix - var newProductPrice = productPrice; // Assume the initial productPrice - var foundNewPrice = false; - if (priceMatrix.length > 0) { - for (var i = 0; i < priceMatrix.length; i++) { - for (var j = 0; j < priceMatrix[i].length; j++) { - if (updatedQuantity <= parseInt(priceMatrix[i][j].quantity)) { - newProductPrice = parseFloat(priceMatrix[i][j].price); - foundNewPrice = true; - break; - } - } - if (foundNewPrice) { - break; - } - } - } + // Check if the updated quantity exceeds the previous price matrix + var newProductPrice = productPrice; + var foundNewPrice = false; + if (priceMatrix.length > 0) { + for (var i = 0; i < priceMatrix.length; i++) { + for (var j = 0; j < priceMatrix[i].length; j++) { + var currentQuantity = parseFloat(priceMatrix[i][j].quantity); + var nextQuantity = (j < priceMatrix[i].length - 1) ? parseFloat(priceMatrix[i][j + 1].quantity) : Infinity; + if (updatedQuantity >= currentQuantity && updatedQuantity < nextQuantity) { + newProductPrice = parseFloat(priceMatrix[i][j].price); + foundNewPrice = true; + break; + } + } + if (foundNewPrice) { + break; + } + } + } - // Update product price if a new price is found in the price matrix - if (foundNewPrice) { - productPrice = newProductPrice; - } + if (foundNewPrice) { + productPrice = newProductPrice; + } - var updateData = { - quantity: updatedQuantity, - price: productPrice // Update the price for the item - }; + var updateData = { + quantity: updatedQuantity, + price: productPrice // Update the price for the item + }; - updateOrderXhr.send(JSON.stringify(updateData)); + updateOrderXhr.send(JSON.stringify(updateData)); - var patchTotalAmountXhr = new XMLHttpRequest(); - patchTotalAmountXhr.open("PATCH", `https:///api/v1/orders/${orderId}`, true); - patchTotalAmountXhr.setRequestHeader("Content-Type", "application/json"); - patchTotalAmountXhr.setRequestHeader("Authorization", "Bearer " + token); + // Patch the total amount of the order with the updated price and quantity + var patchTotalAmountXhr = new XMLHttpRequest(); + patchTotalAmountXhr.open("PATCH", `https:///api/v1/orders/${orderId}`, true); + patchTotalAmountXhr.setRequestHeader("Content-Type", "application/json"); + patchTotalAmountXhr.setRequestHeader("Authorization", "Bearer " + token); - var originalPrice = document.getElementById("productPrice").innerText; - var totalAmount = originalPrice * updatedQuantity; - console.log(originalPrice); - console.log(totalAmount); - var patchData = { - total_amount: totalAmount - }; + var totalAmount = productPrice * updatedQuantity; + var patchData = { + total_amount: totalAmount + }; - patchTotalAmountXhr.send(JSON.stringify(patchData)); - } + patchTotalAmountXhr.send(JSON.stringify(patchData)); + } @@ -1544,14 +1565,14 @@ if (isset($_GET['id'])) {
- "> + "> " /> " /> - + - + - +
@@ -1583,10 +1604,12 @@ if (isset($_GET['id'])) {
- +
">
- + - '; } else { echo '';