From c530e8c7d7fa8bee54d2c7b5937ab634cc0ef6aa Mon Sep 17 00:00:00 2001 From: Jun Barroga Date: Fri, 5 Apr 2024 11:08:15 +0800 Subject: [PATCH 1/6] Modified the Application of Price Matrix When Updating Order --- product-left-sidebar.php | 70 +++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/product-left-sidebar.php b/product-left-sidebar.php index ca03584..9c6821e 100644 --- a/product-left-sidebar.php +++ b/product-left-sidebar.php @@ -1004,49 +1004,47 @@ if (isset($_GET['id'])) { 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; - } - } + 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++) { + if (updatedQuantity <= parseInt(priceMatrix[i][j].quantity)) { + 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; - } +// Update product price if a new price is found in the price matrix +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)); } From d056602c30b90a7e54e5c2766d3d36f05c68e730 Mon Sep 17 00:00:00 2001 From: Jun Barroga Date: Tue, 16 Apr 2024 10:04:25 +0800 Subject: [PATCH 2/6] Apply Price Matrix, Admin Payout Token Renew, Admin Login Redirections --- admin/login.php | 2 +- admin/login_action_admin.php | 41 +++++ admin/token-renew.php | 11 ++ admin/vendor-profile.php | 42 +++-- login_action.php | 2 +- product-left-sidebar.php | 307 +++++++++++++++++++---------------- 6 files changed, 249 insertions(+), 156 deletions(-) create mode 100644 admin/login_action_admin.php create mode 100644 admin/token-renew.php 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 2c2df12..28c69a0 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 9c6821e..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; -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)); -// 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); + // 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 totalAmount = productPrice * updatedQuantity; -var patchData = { - total_amount: totalAmount -}; + var totalAmount = productPrice * updatedQuantity; + var patchData = { + total_amount: totalAmount + }; -patchTotalAmountXhr.send(JSON.stringify(patchData)); - } + patchTotalAmountXhr.send(JSON.stringify(patchData)); + } @@ -1542,14 +1565,14 @@ patchTotalAmountXhr.send(JSON.stringify(patchData));
- "> + "> " /> " /> - + - + - +
@@ -1581,10 +1604,12 @@ patchTotalAmountXhr.send(JSON.stringify(patchData));
- +
">
- + - '; } else { echo ''; From e3a95b604ee037640500c51ab93c41cfc2377776 Mon Sep 17 00:00:00 2001 From: raymart Date: Tue, 16 Apr 2024 10:12:45 +0800 Subject: [PATCH 3/6] Check out Page, Mobile View - bottom navigation bar links issues --- admin/left-main-sidebar.php | 55 ++-- checkouttest.php | 8 +- header.php | 6 +- shop-list-left-sidebar.php | 453 +++++++++++++++++---------------- shop-list-left-sidebar2.php | 489 +++++++++++++++++++----------------- 5 files changed, 527 insertions(+), 484 deletions(-) diff --git a/admin/left-main-sidebar.php b/admin/left-main-sidebar.php index ecffa77..e5c14bc 100644 --- a/admin/left-main-sidebar.php +++ b/admin/left-main-sidebar.php @@ -1,4 +1,14 @@ -
+ + + diff --git a/checkouttest.php b/checkouttest.php index 9b8f509..2255fb1 100644 --- a/checkouttest.php +++ b/checkouttest.php @@ -226,9 +226,13 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
Name: + + +
+
Contact #: @@ -269,7 +273,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
diff --git a/shop-list-left-sidebar.php b/shop-list-left-sidebar.php index cf42a52..265aa73 100644 --- a/shop-list-left-sidebar.php +++ b/shop-list-left-sidebar.php @@ -213,8 +213,11 @@ if (!empty($_GET['minPrice']) || !empty($_GET['maxPrice']) || !empty($_GET['cate
- - + + + +
@@ -321,7 +324,7 @@ if (!empty($_GET['minPrice']) || !empty($_GET['maxPrice']) || !empty($_GET['cate ?>
-
+
-
-
-

Filter Products By

-
-
- -
-
-

Category

-
-
- +
- - - - - -
+
+
+

Filter Products By

- - - +
+
+

Category

+
+
+
+ + + +
+ + +
-
-
    -
  • -
    - S -
    -
  • -
  • -
    - M -
    -
  • -
  • -
    - L -
    -
  • -
  • -
    - XL -
    -
  • -
  • -
    - XXL -
    -
  • -
-
-
--> - - + + + + + +
@@ -781,21 +787,22 @@ if (!empty($_GET['minPrice']) || !empty($_GET['maxPrice']) || !empty($_GET['cate
+
- +
- 3 +
- 4 +
diff --git a/shop-list-left-sidebar2.php b/shop-list-left-sidebar2.php index dd9b201..2151d22 100644 --- a/shop-list-left-sidebar2.php +++ b/shop-list-left-sidebar2.php @@ -138,8 +138,8 @@ if ($_SESSION["userId"] <> "") {
- - + +
@@ -156,6 +156,27 @@ if ($_SESSION["userId"] <> "") {
+ @@ -359,248 +380,250 @@ if ($_SESSION["userId"] <> "") {
-
-
-

Filter Products By

-
-
- -
-
-

Category

-
-
-
- - - -
- +
+
+

Category

+
+
+
+ - -
  • -
    - More - Categories -
    -
  • + +
    + -
    -
    - -
    -
    --> - - + - - +
    +
    +
    --> + + + + +
    @@ -724,16 +747,16 @@ if ($_SESSION["userId"] <> "") {
    - +
    - 3 +
    - 4 +
    From 181b60208779710128c6f01001dd7edf57a287b8 Mon Sep 17 00:00:00 2001 From: Stacy Date: Tue, 16 Apr 2024 10:44:22 +0800 Subject: [PATCH 4/6] Placeholder for Empty List --- user-history.php | 106 ++++++++++++++++++++++++++------- user-refund-history.php | 97 ++++++++++++++++++++++++++++-- vendor-refund-history.php | 121 ++++++++++++++++++++++++++++++++------ 3 files changed, 280 insertions(+), 44 deletions(-) diff --git a/user-history.php b/user-history.php index 3ceed23..ed80055 100644 --- a/user-history.php +++ b/user-history.php @@ -7,6 +7,7 @@ if ($_SESSION["userId"] <> "") { $customer_data = getCustomerbyLoginId($_SESSION["userId"]); } else { $_SESSION["isLoggedIn"] = false; + header("location: login.php"); } ?> @@ -323,7 +324,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -342,29 +343,23 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it - if (isset($order['status']) && isset($order['items'][0]['product'])) { + if (isset($order['status']) && (strtoupper($order['status']) === 'TO PAY') || (strtoupper($order['status']) === 'TO SHIP') + || (strtoupper($order['status']) === 'TO RECEIVE') || (strtoupper($order['status']) === 'COMPLETED') + && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> - - + @@ -374,16 +369,31 @@ if ($_SESSION["userId"] <> "") { - - -

    No Purchased Order/s Yet.

    '; + } } } + // } else if (empty($order['status'])) { + // echo '

    No Purchased Order/s Yet.

    '; + // } ?> + + No Order/s Yet.

    '; + ?> + + +
    Image Name
    - '; - // } else { - // echo 'product'; - // } - ?> - product - product
    product
    @@ -391,7 +401,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -410,12 +420,14 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it if (isset($order['status']) && (strtoupper($order['status']) === 'TO PAY') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> "") { } ?> + + No To Pay Order/s Yet.

    '; + ?> + + +
    Image Name
    @@ -446,7 +470,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -467,12 +491,14 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it if (isset($order['status']) && (strtoupper($order['status']) === 'TO SHIP') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> "") { } ?> + + No To Ship Order/s Yet.

    '; + ?> + + +
    Image Name
    @@ -503,7 +541,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -523,12 +561,14 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it if (isset($order['status']) && (strtoupper($order['status']) === 'TO RECEIVE') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> "") { } ?> + + No To Receive Order/s Yet.

    '; + ?> + + +
    Image Name
    @@ -567,7 +619,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -587,12 +639,14 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it if (isset($order['status']) && (strtoupper($order['status']) === 'COMPLETED') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> @@ -831,6 +885,18 @@ if ($_SESSION["userId"] <> "") { } ?> + + No Completed Order/s Yet.

    '; + ?> + + +
    Image Name
    diff --git a/user-refund-history.php b/user-refund-history.php index 9cda15c..b5f6722 100644 --- a/user-refund-history.php +++ b/user-refund-history.php @@ -9,6 +9,7 @@ if ($_SESSION["userId"] <> "") { $customer_data = getCustomerbyLoginId($_SESSION["userId"]); } else { $_SESSION["isLoggedIn"] = false; + header("location: login.php"); } ?> @@ -338,7 +339,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -359,6 +360,7 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; @@ -367,6 +369,7 @@ if ($_SESSION["userId"] <> "") { if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO APPROVE') || (strtoupper($order['return_order']['status']) === 'TO SHIP') || (strtoupper($order['return_order']['status']) === 'TO RECEIVE') || (strtoupper($order['return_order']['status']) === 'TO REFUND') || (strtoupper($order['return_order']['status']) === 'RETURN COMPLETE') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> "") { } ?> + + No Refund/s Yet.

    '; + ?> + + +
    Image Name
    @@ -399,7 +414,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -420,12 +435,14 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO APPROVE') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> "") { } ?> + + No To Approve Refund/s Yet.

    '; + ?> + + +
    Image Name
    @@ -458,7 +487,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -479,12 +508,14 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO SHIP') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> "") { } ?> + + No To Ship Refund/s Yet.

    '; + ?> + + +
    Image Name
    @@ -517,7 +560,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -538,12 +581,14 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO RECEIVE') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> "") { } ?> + + No To Receive Refund/s Yet.

    '; + ?> + + +
    Image Name
    @@ -579,7 +636,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -600,12 +657,14 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO REFUND') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> "") { } ?> + + No To Refund/s Yet.

    '; + ?> + + +
    Image Name
    @@ -641,7 +712,7 @@ if ($_SESSION["userId"] <> "") {
    - + @@ -661,12 +732,14 @@ if ($_SESSION["userId"] <> "") { $customer = $customer_data[0]; $orders = getOrderbyCustomerId($customer['_id']); $totalAmount = 0; + $orderExist = false; if ($orders) { $order_data = json_decode($orders, true); $_SESSION['cart_items'] = $order_data; foreach ($order_data as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'RETURN COMPLETE') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> "") { } ?> + + No Completed Refund/s Yet.

    '; + ?> + + +
    Image Name
    diff --git a/vendor-refund-history.php b/vendor-refund-history.php index 52efb5a..7d52a7c 100644 --- a/vendor-refund-history.php +++ b/vendor-refund-history.php @@ -311,11 +311,12 @@ if (is_array($vendorOrderss)) {
    Return Complete
    --> + +
    - - + @@ -335,11 +336,13 @@ if (is_array($vendorOrderss)) { $order = $vendorOrders; $orderArray = json_encode($order, true); $orderItems = json_decode($orderArray, true); + $orderExist = false; //for checking if order exist foreach ($orderItems as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO APPROVE') || (strtoupper($order['return_order']['status']) === 'TO SHIP') || (strtoupper($order['return_order']['status']) === 'TO RECEIVE') || (strtoupper($order['return_order']['status']) === 'TO REFUND') || (strtoupper($order['return_order']['status']) === 'RETURN COMPLETE') && isset($order['items'][0]['product'])) { + $orderExist = true; //if there's an order, orderExist will be set to true $totalAmount += $order['total_amount']; ?> + + No Refund/s Yet.

    '; + ?> + + +
    Image Name
    -
    - + + +
    - + @@ -390,9 +405,11 @@ if (is_array($vendorOrderss)) { $order = $vendorOrders; $orderArray = json_encode($order, true); $orderItems = json_decode($orderArray, true); + $orderExist = false; foreach ($orderItems as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO APPROVE') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> + + No To Approve Refund/s Yet.

    '; + ?> + + +
    Image Name
    + +
    - - + @@ -447,9 +476,11 @@ if (is_array($vendorOrderss)) { $order = $vendorOrders; $orderArray = json_encode($order, true); $orderItems = json_decode($orderArray, true); + $orderExist = false; foreach ($orderItems as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO SHIP') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> + + No To Ship Refund/s Yet.

    '; + ?> + + +
    Image Name
    + +
    - - + @@ -499,9 +542,11 @@ if (is_array($vendorOrderss)) { $order = $vendorOrders; $orderArray = json_encode($order, true); $orderItems = json_decode($orderArray, true); + $orderExist = false; foreach ($orderItems as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO RECEIVE') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> + + No To Receive Refund/s Yet.

    '; + ?> + + +
    Image Name
    + +
    - - + @@ -553,9 +611,11 @@ if (is_array($vendorOrderss)) { $order = $vendorOrders; $orderArray = json_encode($order, true); $orderItems = json_decode($orderArray, true); + $orderExist = false; foreach ($orderItems as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'TO REFUND') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> + + No To Refund/s Yet.

    '; + ?> + + +
    Image Name
    + +
    - - + @@ -608,9 +680,11 @@ if (is_array($vendorOrderss)) { $order = $vendorOrders; $orderArray = json_encode($order, true); $orderItems = json_decode($orderArray, true); + $orderExist = false; foreach ($orderItems as $order) { // Ensure that the required data is available before accessing it if (isset($order['return_order']['status']) && (strtoupper($order['return_order']['status']) === 'RETURN COMPLETE') && isset($order['items'][0]['product'])) { + $orderExist = true; $totalAmount += $order['total_amount']; ?> + + No Refund/s Complete Yet.

    '; + ?> + + +
    Image Name
    From a475ceecbaa16ad3136eab4933a48a07cdaf53e9 Mon Sep 17 00:00:00 2001 From: Stacy Date: Tue, 16 Apr 2024 10:47:29 +0800 Subject: [PATCH 5/6] Minor Changes --- user-profile.php | 3 ++- vendor-dashboard.php | 4 ++-- vendor-settings.php | 4 ++-- vendor-uploads.php | 2 +- wishlist.php | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/user-profile.php b/user-profile.php index e3ae4f4..b9e01b6 100644 --- a/user-profile.php +++ b/user-profile.php @@ -9,6 +9,7 @@ if ($_SESSION["userId"] <> "") { $customer_data = getCustomerbyLoginId($_SESSION["userId"]); } else { $_SESSION["isLoggedIn"] = false; + header("location: login.php"); } ?> @@ -513,7 +514,7 @@ if ($_SESSION["userId"] <> "") { }) .then(response => { if (response.ok) { - location.reload(); + // location.reload(); // filter the delete action document.getElementById('form-check-' + addressIndex).remove(); } else { diff --git a/vendor-dashboard.php b/vendor-dashboard.php index 38ae990..4223c08 100644 --- a/vendor-dashboard.php +++ b/vendor-dashboard.php @@ -265,7 +265,7 @@ if (is_array($vendorOrderss)) { } ?> --> - + @@ -463,7 +463,7 @@ if (is_array($vendorOrderss)) { } ?> --> - + diff --git a/vendor-settings.php b/vendor-settings.php index 55a579d..30dd44c 100644 --- a/vendor-settings.php +++ b/vendor-settings.php @@ -629,7 +629,7 @@ if ($_SESSION["userId"] <> "") {