diff --git a/checkouttest.php b/checkouttest.php index 32373d1..91ec43d 100644 --- a/checkouttest.php +++ b/checkouttest.php @@ -83,6 +83,8 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] + + @@ -105,6 +107,13 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] }); } + + @@ -252,19 +261,29 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] -
+ $customer) { ?> $address) { ?> -
+ +
-
@@ -278,6 +297,50 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] - '; - } else { - echo ' - - Place Order - '; - } - ?> + Place Order
@@ -1026,30 +1401,6 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] const randomIndex = Math.floor(Math.random() * refchar.length); uniqueRef += refchar.charAt(randomIndex); } - - const selectedFName = document.getElementById('selectedFName').innerText; - const selectedLName = document.getElementById('selectedLName').innerText; - const selectedContact = document.getElementById('selectedContact').innerText; - const sBuilding = document.getElementById('sBuilding').innerText; - const sStreet = document.getElementById('sStreet').innerText; - const sCity = document.getElementById('sCity').innerText; - const sBarangay = document.getElementById('sBarangay').innerText; - const sProvince = document.getElementById('sProvince').innerText; - const sCountry = document.getElementById('sCountry').innerText; - if ( - selectedFName.trim() === "" || - selectedLName.trim() === "" || - selectedContact.trim() === "" || - sBuilding.trim() === "" || - sStreet.trim() === "" || - sCity.trim() === "" || - sBarangay.trim() === "" || - sProvince.trim() === "" || - sCountry.trim() === "" - ) { - alert("Please select address."); - return; // Stop further execution - } newArray.forEach(async (orderId) => { console.log(orderId) const token = ''; @@ -1103,7 +1454,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] 'Authorization': "Bearer " + token, }, }); - + // added marhc 7 2024 if (!patchResponse.ok) { throw new Error(`Error updating payment status: ${patchResponse.status} ${patchResponse.statusText}`); } diff --git a/vendor-all-product-list.php b/vendor-all-product-list.php index 1b60653..9519ddb 100644 --- a/vendor-all-product-list.php +++ b/vendor-all-product-list.php @@ -64,6 +64,8 @@ $products = productList(); + + @@ -138,9 +140,12 @@ $products = productList();
Product List
-
+
- Add + + Delete Selected + + Add
@@ -166,8 +171,10 @@ $products = productList(); for ($i = 0; $i <= $totalProducts - 1; $i++) { $product = $products[$i]; ?> - + + + - - - + + + + + + - + @@ -223,6 +233,7 @@ $products = productList(); var email = ''; var password = ''; + function deleteProduct(productId) { let text = "Please confirm delete action!\nClick OK or Cancel button."; if (confirm(text) == true) { @@ -295,13 +306,54 @@ $products = productList(); // function editProduct(productId) { // window.open("vendor-uploads.php?id=" + productId, "_self"); // } - function addProduct() { + function addProduct(productId) { console.log("Session Token:", sessionToken); login(email, password, function() { // Removed the call to updateSessionToken - window.open("vendor-uploads-add-product-action.php", "_self"); + window.open("vendor-uploads-add-product-action.php" + productId, "_self"); }); } + + // multiple delete when checking the checkbox + function deleteSelectedProduct() { + var checkboxes = document.querySelectorAll('input[name="product_checkbox[]"]:checked'); + if (checkboxes.length === 0) { + alert('Please select at least one product to delete.'); + return; + } + var selectedProductIds = []; + checkboxes.forEach(function (checkbox) { + selectedProductIds.push(checkbox.value); + }); + var text = "Please confirm delete action!\nClick OK or Cancel button."; + if (confirm(text) == true) { + selectedProductIds.forEach(function(productId) { + fetch("https:///api/v1/products/" + productId, { + method: "DELETE" + }) + .then(response => { + if (response.ok) { + console.log("Product with ID " + productId + " deleted successfully."); + // Remove the deleted product row from the table + var productRow = document.getElementById(productId); + if (productRow) { + productRow.remove(); + } else { + console.error("Product row with ID " + productId + " not found in the DOM."); + } + } else { + throw new Error("Error deleting product with ID " + productId + ": " + response.statusText); + } + }) + .catch(error => { + console.error(error.message); + }); + }); + } + } + + +