Minor Bug Fixes and Initial Application of Price Matrix
This commit is contained in:
parent
0f4d180411
commit
10ccc1d7fe
|
@ -1151,11 +1151,9 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
$freeShipping = true;
|
||||
}
|
||||
|
||||
// Set the shipping fee based on the condition
|
||||
$shippingFee = $freeShipping ? 0 : $checkout['shipping_fee'];
|
||||
|
||||
// Calculate total amount for each item
|
||||
$totalAmount += ($item['price'] + $shippingFee) * $item['quantity'];
|
||||
$totalAmount += ($item['price'] * $item['quantity']) + $shippingFee ;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1288,6 +1286,30 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
}
|
||||
} else if (pay2RadioButton.checked) {
|
||||
try {
|
||||
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;
|
||||
}
|
||||
|
||||
<?php foreach ($cartItems as $checkout) { ?>
|
||||
<?php foreach ($checkout['items'] as $item) { ?>
|
||||
itemNames.push("<?php echo str_replace('"', "\\'", $item['product']['name']) . ' (' . $item['quantity'] . ')'; ?>");
|
||||
|
@ -1335,15 +1357,15 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
method: "PATCH",
|
||||
body: JSON.stringify({
|
||||
shipping_address: {
|
||||
shipping_first_name: document.getElementById('selectedFName').innerText,
|
||||
shipping_last_name: document.getElementById('selectedLName').innerText,
|
||||
shipping_phone: document.getElementById('selectedContact').innerText,
|
||||
shipping_address_1: document.getElementById('sBuilding').innerText,
|
||||
shipping_address_2: document.getElementById('sStreet').innerText,
|
||||
shipping_city: document.getElementById('sCity').innerText,
|
||||
shipping_barangay: document.getElementById('sBarangay').innerText,
|
||||
shipping_state: document.getElementById('sProvince').innerText,
|
||||
shipping_country: document.getElementById('sCountry').innerText,
|
||||
shipping_first_name: selectedFName,
|
||||
shipping_last_name: selectedLName,
|
||||
shipping_phone: selectedContact,
|
||||
shipping_address_1: sBuilding,
|
||||
shipping_address_2: sStreet,
|
||||
shipping_city: sCity,
|
||||
shipping_barangay: sBarangay,
|
||||
shipping_state: sProvince,
|
||||
shipping_country: sCountry,
|
||||
},
|
||||
billing_address: {
|
||||
billing_first_name: billingFName,
|
||||
|
@ -1367,8 +1389,6 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': "Bearer " + token,
|
||||
|
||||
// Add any additional headers as needed
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -1376,25 +1396,14 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
throw new Error(`Error updating payment status: ${patchResponse.status} ${patchResponse.statusText}`);
|
||||
}
|
||||
})
|
||||
// Handle the result of the original POST request as needed
|
||||
console.log("COD Successfull")
|
||||
console.log("Payment Successfull")
|
||||
window.location.href = 'user-history.php';
|
||||
// console.log( <?php echo $filteredIdsJSON; ?>);
|
||||
|
||||
|
||||
// const patchResult = await patchResponse.json();
|
||||
// console.log(patchResult);
|
||||
|
||||
// Handle the result of the PATCH request as needed
|
||||
}
|
||||
|
||||
// Handle the result of the original POST request as needed
|
||||
// window.open(result.attributes.checkout_url);
|
||||
window.location.href = result.attributes.checkout_url;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
// Handle errors
|
||||
}
|
||||
|
||||
} else if (pay3RadioButton.checked) {
|
||||
|
@ -1432,7 +1441,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
sCountry.trim() === ""
|
||||
) {
|
||||
alert("Please select address.");
|
||||
return; // Stop further execution
|
||||
return;
|
||||
}
|
||||
newArray.forEach(async (orderId) => {
|
||||
console.log(orderId)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
|
||||
include "functions.php";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
|
|
@ -51,7 +51,7 @@ function sddProducts()
|
|||
curl_close($curl);
|
||||
$json = json_decode($response, true);
|
||||
$products = array_filter($json, function ($var) {
|
||||
return ($var['promo'][0]['same-day-delivery'] === "Yes" && $var['product_type'] == '' || $var['promo'][0]['same-day-delivery'] === "Yes" && $var['product_type'] == 'simple' || $var['promo'][0]['same-day-delivery'] === "Yes" && $var['product_type'] == 'variable');
|
||||
return ($var['promo'][0]['next-day-delivery'] === "Yes" && $var['product_type'] == '' || $var['promo'][0]['next-day-delivery'] === "Yes" && $var['product_type'] == 'simple' || $var['promo'][0]['next-day-delivery'] === "Yes" && $var['product_type'] == 'variable');
|
||||
});
|
||||
$products = array_values($products);
|
||||
return $products;
|
||||
|
|
|
@ -897,7 +897,7 @@ if ($_SESSION["userId"] <> "") {
|
|||
<li><a href="privacy-policy.html">Privacy Policy</a></li>
|
||||
</ul> -->
|
||||
</li>
|
||||
<li class="dropdown"><span class="main-label-note-new" data-toggle="tooltip" title="NEW"></span><a href="same_day_delivery.php">Next-Day-Delivery</a>
|
||||
<li class="dropdown"><span class="main-label-note-new" data-toggle="tooltip" title="NEW"></span><a href="next_day_delivery.php">Next-Day-Delivery</a>
|
||||
<!-- <ul class="sub-menu">
|
||||
<li class="dropdown position-static"><a href="javascript:void(0)">Mail
|
||||
Confirmation
|
||||
|
|
|
@ -211,17 +211,17 @@ if ($_SESSION["userId"] <> "") {
|
|||
$vendorOfProduct = getVendorbyId($simpleProducts[$pid]['vendor_api_id']);
|
||||
?>
|
||||
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-6 mb-6 pro-gl-content">
|
||||
<div class="ec-product-inner">
|
||||
<div class="ec-product-inner" style="width: 260px;">
|
||||
<div class="ec-pro-image-outer">
|
||||
<div class="ec-pro-image">
|
||||
<a href="shop-left-sidebar-col-4.php" class="image">
|
||||
<a href="product-left-sidebar.php?id=<?php echo $simpleProducts[$pid]["_id"]; ?>" >
|
||||
<?php
|
||||
if (isset($simpleProducts[$pid]['images'])) {
|
||||
$image_urls = explode(',', $simpleProducts[$pid]['images']);
|
||||
if (!empty($image_urls)) {
|
||||
$first_image_url = trim($image_urls[0]);
|
||||
?>
|
||||
<img class="ec-image-preview" src="<?php echo $first_image_url; ?>" alt="edit" />
|
||||
<img class="main-image" src="<?php echo $first_image_url; ?>" alt="edit" style="border: 1px solid #eeeeee; height: 280px; width: 100%;"/>
|
||||
<?php
|
||||
}
|
||||
} else {
|
|
@ -374,15 +374,14 @@ if (isset($_GET['id'])) {
|
|||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="ec-single-price-stoke">
|
||||
<div class="ec-single-price">
|
||||
<span class="ec-single-ps-title">As low as</span>
|
||||
<?php
|
||||
// 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 '<s><span id="productPrice" class="old-price">₱' . $product_details['regular_price'] . '</span></s>';
|
||||
echo '<span id="productNewPrice" class="new-price">₱' . $product_details['sale_price'] . '</span>';
|
||||
echo '<s><span id="productPrice" class="old-price">' . $product_details['regular_price'] . '</span></s>';
|
||||
echo '<span id="productNewPrice" class="new-price">' . $product_details['sale_price'] . '</span>';
|
||||
} elseif (!isset($product_details['regular_price']) || $product_details['regular_price'] <= 0) {
|
||||
echo '<span id="productPrice" class="new-price">Contact Seller for Price</span>';
|
||||
} else {
|
||||
|
@ -763,6 +762,7 @@ if (isset($_GET['id'])) {
|
|||
console.log("Button clicked");
|
||||
|
||||
login(email, password, function(token) {
|
||||
var priceMatrix = <?php echo (!empty($product_details['price_matrix'])) ? json_encode($product_details['price_matrix']) : "[]"; ?>;
|
||||
var quantityValue = document.getElementById("qty-input").value;
|
||||
var minimumOrder = <?php echo (!empty($product_details['minimum_order'])) ? $product_details['minimum_order'] : "1"; ?>;
|
||||
var shippingFee = "<?php echo isset($product_details['shipping_fee']) && $product_details['shipping_fee'] !== '' ? $product_details['shipping_fee'] : '50'; ?>";
|
||||
|
@ -771,19 +771,42 @@ if (isset($_GET['id'])) {
|
|||
alert("The minimum order quantity is " + minimumOrder);
|
||||
}
|
||||
|
||||
// April 3, 2024 Jun Jihad Apply Matrix
|
||||
var productPrice;
|
||||
var foundPrice = false;
|
||||
|
||||
if (priceMatrix.length > 0) {
|
||||
for (var i = 0; i < priceMatrix.length; i++) {
|
||||
for (var j = 0; j < priceMatrix[i].length; j++) {
|
||||
if (quantityValue <= parseInt(priceMatrix[i][j].quantity)) {
|
||||
productPrice = parseFloat(priceMatrix[i][j].price);
|
||||
foundPrice = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundPrice) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundPrice) {
|
||||
productPrice = parseFloat(document.getElementById("productNewPrice") ? document.getElementById("productNewPrice").innerText : document.getElementById("productPrice").innerText);
|
||||
}
|
||||
var productData = {
|
||||
product: {
|
||||
product_image: document.getElementById("mainProductImage").getAttribute('src'),
|
||||
product_id: document.getElementById("product_Id").value,
|
||||
name: document.getElementById("productTitle").innerText,
|
||||
},
|
||||
price: document.getElementById("productNewPrice") ? document.getElementById("productNewPrice").innerText : document.getElementById("productPrice").innerText,
|
||||
price: productPrice,
|
||||
quantity: quantityValue,
|
||||
vendor_id: "<?php echo $vendor_details['_id'] ?>",
|
||||
vendor_name: "<?php echo $vendor_details['user_login'] ?>",
|
||||
};
|
||||
// April 3, 2024 Jun Jihad Apply Matrix
|
||||
|
||||
console.log("Product data:", productData); // Debugging statement
|
||||
console.log("Product data:", productData);
|
||||
|
||||
var totalAmount = productData.price * productData.quantity;
|
||||
|
||||
|
@ -793,7 +816,7 @@ if (isset($_GET['id'])) {
|
|||
name: "<?php echo $customer['first_name']; ?> <?php echo $customer['last_name']; ?>",
|
||||
};
|
||||
|
||||
console.log("Customer data:", customerData); // Debugging statement
|
||||
console.log("Customer data:", customerData);
|
||||
|
||||
// Check if the product is already in the order API
|
||||
var existingOrder;
|
||||
|
@ -842,7 +865,7 @@ if (isset($_GET['id'])) {
|
|||
shipping_fee: shippingFee,
|
||||
};
|
||||
|
||||
console.log("Request data:", requestData); // Debugging statement
|
||||
console.log("Request data:", requestData);
|
||||
// const token = '<?php echo $_SESSION["token"] ?>';
|
||||
xhr.open("POST", "https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/json", );
|
||||
|
@ -852,7 +875,7 @@ if (isset($_GET['id'])) {
|
|||
if (xhr.status === 201) {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
|
||||
console.log("Response:", response); // Debugging statement
|
||||
console.log("Response:", response);
|
||||
|
||||
// Update the cart dynamically
|
||||
var cartList = document.querySelector(".eccart-pro-items");
|
||||
|
@ -922,24 +945,24 @@ if (isset($_GET['id'])) {
|
|||
}
|
||||
|
||||
function updateOrder(orderId, existingItemId) {
|
||||
var updateOrderXhr = new XMLHttpRequest();
|
||||
// const token = '<?php echo $_SESSION["token"] ?>';
|
||||
updateOrderXhr.open("PUT", `https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders/${orderId}/items/${existingItemId}`, true);
|
||||
updateOrderXhr.setRequestHeader("Content-Type", "application/json");
|
||||
updateOrderXhr.setRequestHeader("Authorization", "Bearer " + token);
|
||||
updateOrderXhr.onreadystatechange = function() {
|
||||
if (updateOrderXhr.readyState === 4) {
|
||||
if (updateOrderXhr.status === 200) {
|
||||
var response = JSON.parse(updateOrderXhr.responseText);
|
||||
console.log("Order updated:", response);
|
||||
var updateOrderXhr = new XMLHttpRequest();
|
||||
// const token = '<?php echo $_SESSION["token"] ?>';
|
||||
updateOrderXhr.open("PUT", `https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders/${orderId}/items/${existingItemId}`, true);
|
||||
updateOrderXhr.setRequestHeader("Content-Type", "application/json");
|
||||
updateOrderXhr.setRequestHeader("Authorization", "Bearer " + token);
|
||||
updateOrderXhr.onreadystatechange = function() {
|
||||
if (updateOrderXhr.readyState === 4) {
|
||||
if (updateOrderXhr.status === 200) {
|
||||
var response = JSON.parse(updateOrderXhr.responseText);
|
||||
console.log("Order updated:", response);
|
||||
|
||||
var cartItem = document.getElementById(`order_${response._id}`);
|
||||
var cartItem = document.getElementById(`order_${response._id}`);
|
||||
|
||||
if (cartItem) {
|
||||
var updatedQuantity = response.items[0].quantity; // Use the correct quantity from the updated order
|
||||
var totalAmount = response.items[0].price * updatedQuantity;
|
||||
// If the cart item already exists, update its content using innerHTML
|
||||
cartItem.innerHTML = `
|
||||
if (cartItem) {
|
||||
var updatedQuantity = response.items[0].quantity;
|
||||
var totalAmount = response.items[0].price * updatedQuantity;
|
||||
// If the cart item already exists, update its content using innerHTML
|
||||
cartItem.innerHTML = `
|
||||
<a href="shop-left-sidebar-col-4.php" class="sidekka_pro_img">
|
||||
<img src="${response.items[0].product.product_image}" alt="product">
|
||||
</a>
|
||||
|
@ -957,50 +980,74 @@ if (isset($_GET['id'])) {
|
|||
<a href="#" class="removeCart" onclick="deleteOrder('${response._id}')">x</a>
|
||||
</div>
|
||||
`;
|
||||
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;
|
||||
|
||||
var updateData = {
|
||||
quantity: updatedQuantity,
|
||||
};
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateOrderXhr.send(JSON.stringify(updateData));
|
||||
// Update product price if a new price is found in the price matrix
|
||||
if (foundNewPrice) {
|
||||
productPrice = newProductPrice;
|
||||
}
|
||||
|
||||
var patchTotalAmountXhr = new XMLHttpRequest();
|
||||
patchTotalAmountXhr.open("PATCH", `https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders/${orderId}`, true);
|
||||
patchTotalAmountXhr.setRequestHeader("Content-Type", "application/json");
|
||||
patchTotalAmountXhr.setRequestHeader("Authorization", "Bearer " + token);
|
||||
var updateData = {
|
||||
quantity: updatedQuantity,
|
||||
price: productPrice // Update the price for the item
|
||||
};
|
||||
|
||||
var originalPrice = document.getElementById("productPrice").innerText;
|
||||
var totalAmount = originalPrice * updatedQuantity;
|
||||
console.log(originalPrice);
|
||||
console.log(totalAmount);
|
||||
var patchData = {
|
||||
total_amount: totalAmount
|
||||
};
|
||||
updateOrderXhr.send(JSON.stringify(updateData));
|
||||
|
||||
patchTotalAmountXhr.send(JSON.stringify(patchData));
|
||||
}
|
||||
var patchTotalAmountXhr = new XMLHttpRequest();
|
||||
patchTotalAmountXhr.open("PATCH", `https://<?php echo $_SESSION["data_endpoint"]; ?>/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
|
||||
};
|
||||
|
||||
patchTotalAmountXhr.send(JSON.stringify(patchData));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -597,13 +597,22 @@ if ($_SESSION["userId"] <> "") {
|
|||
<td><span><?php echo $order['courier_name']; ?></span></td> -->
|
||||
<td><span><?php echo date("F j, Y", strtotime($order['updatedAt'])); ?></span></td>
|
||||
<td>
|
||||
<?php
|
||||
<?php
|
||||
$currentDate = time(); // Current Unix timestamp
|
||||
|
||||
if ($order['return_order']['status'] === 'To Approve') {
|
||||
echo '<span class="tbl-btn">Refund Requested</span>';
|
||||
} elseif ($order['return_order']['status'] === 'To Ship') {
|
||||
echo '<span class="tbl-btn">For Refund</span>';
|
||||
}else {
|
||||
echo '<a class="btn btn-lg btn-primary" data-bs-toggle="modal" data-bs-target="#modal-refund-' . $order['_id'] . '">Return/Refund</a>';
|
||||
} else {
|
||||
$orderDate = strtotime($order['updatedAt']);
|
||||
$sevenDaysAfterOrder = strtotime('+7 days', $orderDate); // Seven days after the order date
|
||||
|
||||
if ($currentDate >= $sevenDaysAfterOrder) {
|
||||
echo '<span class="tbl-btn" disabled></span>';
|
||||
} else {
|
||||
echo '<a class="btn btn-lg btn-primary" data-bs-toggle="modal" data-bs-target="#modal-refund-' . $order['_id'] . '">Return/Refund</a>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
|
|
@ -181,7 +181,7 @@ $products = productList();
|
|||
|
||||
<a class="btn btn-lg btn-primary" onclick="deleteSelectedProduct('<?php echo $product['_id'] ?>');">Delete Selected</a>
|
||||
|
||||
<a class="btn btn-lg btn-primary" href="vendor-uploads-add-product-action.php" onclick="addProduct('<?php echo $product['_id'] ?>');">Add</a>
|
||||
<a class="btn btn-lg btn-primary" onclick="addProduct('<?php echo $product['_id'] ?>');">Add</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ec-vendor-card-body">
|
||||
|
@ -362,7 +362,8 @@ $products = productList();
|
|||
console.log("Session Token:", sessionToken);
|
||||
login(email, password, function() {
|
||||
// Removed the call to updateSessionToken
|
||||
window.open("vendor-uploads-add-product-action.php" + productId, "_self");
|
||||
// window.open("vendor-uploads-add-product-action.php" + productId, "_self");
|
||||
window.location.href = "vendor-uploads-add-product-action.php?productId=" + productId;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ $array = json_decode($result, true);
|
|||
<div class="thumb-upload">
|
||||
<div class="thumb-edit">
|
||||
<input type='file' id="thumbUpload<?php echo $index + 1; ?>" class="ec-image-upload" accept=".png, .jpg, .jpeg" />
|
||||
<label for="thumbUpload<?php echo $index + 1; ?>"><i class="fi-rr-edit"></i></label>
|
||||
<!-- <label for="thumbUpload<?php echo $index + 1; ?>"><i class="fi-rr-edit"></i></label> -->
|
||||
</div>
|
||||
<div class="thumb-preview ec-preview">
|
||||
<div class="image-thumb-preview">
|
||||
|
@ -396,15 +396,24 @@ $array = json_decode($result, true);
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody id="price-matrix-body">
|
||||
<?php foreach ($array['price_matrix'][0] as $index => $pair) : ?>
|
||||
<tr data-row-index="<?php echo $index; ?>">
|
||||
<td><input type="number" class="form-control" name="quantity[]" value="<?php echo $pair['quantity']; ?>"></td>
|
||||
<td><input type="number" class="form-control" name="price[]" value="<?php echo $pair['price']; ?>"></td>
|
||||
<?php if (empty($array['price_matrix'][0])) : ?>
|
||||
<tr data-row-index="0">
|
||||
<td><input type="number" class="form-control" name="quantity[]"></td>
|
||||
<td><input type="number" class="form-control" name="price[]"></td>
|
||||
<td><button type="button" class="btn btn-danger delete-row">Delete</button></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<?php foreach ($array['price_matrix'][0] as $index => $pair) : ?>
|
||||
<tr data-row-index="<?php echo $index; ?>">
|
||||
<td><input type="number" class="form-control" name="quantity[]" value="<?php echo $pair['quantity']; ?>"></td>
|
||||
<td><input type="number" class="form-control" name="price[]" value="<?php echo $pair['price']; ?>"></td>
|
||||
<td><button type="button" class="btn btn-danger delete-row">Delete</button></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
|
||||
|
||||
</table>
|
||||
<button type="button" class="btn btn-secondary" id="add-row">Add Row</button>
|
||||
</div>
|
||||
|
@ -413,19 +422,19 @@ $array = json_decode($result, true);
|
|||
<div class="col-md-12" style="margin: 0 0 20px 0;">
|
||||
<label class="form-label">Promo</label>
|
||||
<div class="row" justify-content-between>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-6">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="nextDayDeliveryCheckbox" name="promo[next-day-delivery]" value="Yes" <?php if ($array['promo'][0]['next-day-delivery'] === "Yes") echo "checked"; ?> style="background-color: blue;">
|
||||
<label class="form-check-label" for="nextDayDeliveryCheckbox">Next Day Delivery</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<!-- <div class="col-md-4">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="sameDayDeliveryCheckbox" name="promo[same-day-delivery]" value="Yes" <?php if ($array['promo'][0]['same-day-delivery'] === "Yes") echo "checked"; ?> style="background-color: blue;">
|
||||
<label class="form-check-label" for="sameDayDeliveryCheckbox">Same Day Delivery</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
</div> -->
|
||||
<div class="col-md-6">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" id="freeShippingCheckbox" name="promo[free-shipping]" value="Yes" <?php if ($array['promo'][0]['free-shipping'] === "Yes") echo "checked"; ?> style="background-color: blue;">
|
||||
<label class="form-check-label" for="freeShippingCheckbox">Free Shipping</label>
|
||||
|
@ -721,7 +730,7 @@ $array = json_decode($result, true);
|
|||
|
||||
Promise.all(promises)
|
||||
.then(filenames => {
|
||||
const updatedImages = existingImages.concat(filenames.map(filename => `https://<?php echo $_SESSION["data_endpoint"]; ?>/images/storage/product_uploads/${filename}`));
|
||||
const updatedImages = existingImages.concat(filenames.map(filename => `https://<?php echo $_SESSION["data_endpoint"]; ?>/images/storage/product_uploads/${encodeURIComponent(filename)}`));
|
||||
|
||||
if (!Array.isArray(updatedImages)) {
|
||||
console.error('Updated images is not an array:', updatedImages);
|
||||
|
|
Loading…
Reference in New Issue