Compare commits
7 Commits
8982f54971
...
cd922a186f
Author | SHA1 | Date |
---|---|---|
raymart | cd922a186f | |
raymart | 157edf72a8 | |
MarkHipe | 00b4ca7a61 | |
Jun Barroga | 2e505256f6 | |
MarkHipe | 78d0915ba2 | |
Stacy | f91e552a89 | |
MarkHipe | 214aa11028 |
|
@ -66,6 +66,9 @@ $products = productList();
|
|||
<!-- FAVICON -->
|
||||
<link href="assets/img/favicon.png" rel="shortcut icon" />
|
||||
|
||||
<!-- FONTAWESOME -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
@ -744,9 +747,50 @@ $products = productList();
|
|||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 02-28-2024 Stacy modified this block of code -->
|
||||
<div class="modal-body pt-0">
|
||||
<div style="text-align: center; display: flex; justify-content: center; align-items: center;" class="col-md-6">
|
||||
<input type="file" id="fileInput<?php echo $vendor['_id']; ?>" />
|
||||
<div style="text-align: center; display: column; justify-content: center; align-items: center;" class="col-md-6">
|
||||
<!-- <input type="file" id="fileInput<?php #echo $vendor['_id']; ?>" accept=".png, .jpg, .jpeg" /> -->
|
||||
<div class="thumb-edit" style="padding-left:120px; margin-bottom:-40px;">
|
||||
<input style="display:none;" type='file' id="fileInput<?php echo $vendor['_id']; ?>" class="ec-image-upload" accept=".png, .jpg, .jpeg" onchange="previewImage('<?php echo $vendor['_id']; ?>')"/>
|
||||
<label><i class="fa-solid fa-file-import" style="cursor:pointer;" onclick="document.getElementById('fileInput<?php echo $vendor['_id']; ?>').click()"></i></label>
|
||||
|
||||
</div>
|
||||
<div class="vendor-image" style="padding-top:20px; ">
|
||||
<?php
|
||||
if (isset($vendor['vendor_image']) && !empty($vendor['vendor_image'])) {
|
||||
echo '<img src="' . $vendor['vendor_image'] . '" alt="edit" id="imgPrev" class="img-fluid rounded-circle" alt="Avatar Image" style="align-items:left; width:100px; height:100px; object-fit:cover; border-radius:80%;"> ';
|
||||
} else {
|
||||
echo '<img src="https://yourteachingmentor.com/wp-content/uploads/2020/12/istockphoto-1223671392-612x612-1.jpg" id="imgPrev" alt="edit" class="img-fluid rounded-circle" alt="Placeholder Image" style="align-items:left; width:80px; height:80px; object-fit:cover; border-radius:50%;">';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function updateButtonText(input){
|
||||
var label = document.getElementById('fileInputLabel');
|
||||
if (input.files.length > 0) {
|
||||
label.innerHTML = '<i class="fa-solid fa-file-arrow-up"></i> ' + input.files[0].name;
|
||||
}else{
|
||||
label.innerHTML = '<i class="fa-solid fa-file-arrow-up"></i> Upload file';
|
||||
}
|
||||
}
|
||||
|
||||
// 02-29-2024 Stacy for image preview
|
||||
function previewImage(vendorId){
|
||||
var fileInput = document.getElementById('fileInput' + vendorId);
|
||||
var file = fileInput.files[0];
|
||||
console.log('clicked hereee')
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
const dataUri = e.target.result;
|
||||
document.getElementById('imgPrev').src=dataUri
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
<form>
|
||||
<div class="row no-gutters">
|
||||
|
@ -755,7 +799,7 @@ $products = productList();
|
|||
<div class="text-center widget-profile px-0 border-0">
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="user_login-<?php echo $vendor['_id']; ?>" class="text-dark font-weight-medium pt-3 mb-2">Name</label>
|
||||
<label for="user_login-<?php echo $vendor['_id']; ?>" class="text-dark font-weight-medium pt-3 mb-2"><i class="fi-rr-edit"></i>Name</label>
|
||||
<input type="text" class="form-control" id="user_login-<?php echo $vendor['_id']; ?>" value="<?php echo $vendor['user_login']; ?>">
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -801,7 +845,7 @@ $products = productList();
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-6" style="margin-top:-100px;">
|
||||
<div class="contact-info px-4">
|
||||
<h4 class="text-dark mb-1">Address</h4>
|
||||
|
||||
|
@ -873,6 +917,8 @@ $products = productList();
|
|||
var fileInput = document.getElementById('fileInput' + vendorId);
|
||||
var file = fileInput.files[0];
|
||||
|
||||
|
||||
|
||||
const updatedUser = document.getElementById('user_login-' + vendorId).value;
|
||||
const firstName = document.getElementById('firstName-' + vendorId).value;
|
||||
const lastName = document.getElementById('lastName-' + vendorId).value;
|
||||
|
@ -891,6 +937,8 @@ $products = productList();
|
|||
formData.append('category', 'vendor');
|
||||
formData.append('image', file); // Include the file data in the form data
|
||||
|
||||
if(file){
|
||||
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/upload_image', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
|
@ -944,6 +992,46 @@ $products = productList();
|
|||
.catch(error => {
|
||||
console.error('Error during fetch:', error);
|
||||
});
|
||||
|
||||
}else{
|
||||
const payload = {
|
||||
vendor_image: `https://<?php echo $_SESSION["data_endpoint"]; ?>/images/storage/vendor_uploads/${filename}`,
|
||||
user_login: updatedUser,
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
user_email: updatedEmail,
|
||||
phone: phone,
|
||||
vendor_description: description,
|
||||
status: status,
|
||||
address: [{
|
||||
address_1: updatedAddress1,
|
||||
address_2: updatedAddress2,
|
||||
barangay: barangay,
|
||||
city: city,
|
||||
province: province,
|
||||
country: country,
|
||||
}]
|
||||
};
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorId, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
location.reload();
|
||||
|
||||
return response.json();
|
||||
} else {
|
||||
console.error('vendor Update failed');
|
||||
throw new Error('vendor Update failed');
|
||||
}
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}else {
|
||||
|
@ -971,6 +1059,8 @@ $products = productList();
|
|||
formData.append('category', 'vendor');
|
||||
formData.append('image', file);
|
||||
|
||||
if (file){
|
||||
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/upload_image', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
|
@ -1025,6 +1115,44 @@ $products = productList();
|
|||
.catch(error => {
|
||||
console.error('Error during fetch:', error);
|
||||
});
|
||||
}else{
|
||||
|
||||
const payload = {
|
||||
user_login: updatedUser,
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
user_email: updatedEmail,
|
||||
phone: phone,
|
||||
vendor_description: description,
|
||||
status: status,
|
||||
address: [{
|
||||
address_1: updatedAddress1,
|
||||
address_2: updatedAddress2,
|
||||
barangay: barangay,
|
||||
city: city,
|
||||
province: province,
|
||||
country: country,
|
||||
}]
|
||||
};
|
||||
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/vendors/' + vendorId, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
location.reload();
|
||||
return response.json();
|
||||
} else {
|
||||
console.error('vendor Update failed');
|
||||
throw new Error('vendor Update failed');
|
||||
}
|
||||
})
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -690,7 +690,6 @@ function popupAddToCart(product, productVendor, token, email, password, customer
|
|||
Unit Price: <span>${response.items[0].price}</span>
|
||||
</span>
|
||||
<span id="subtotal-${response._id}" class="subtotal-${response._id}">Subtotal: ${totalAmount}</span>
|
||||
// raymart feb 26 2024
|
||||
<div class="qty-plus-minuses" style="display:flex; overflow:visible; align-items:center; padding-top:10px;">
|
||||
<div class="qty-btn" style="color:#ffaa00; font-size:35px; padding-right:5px; cursor: pointer;" onclick="qtyDecrement('${response._id}', '${response.items[0]._id}', true)">-</div>
|
||||
<input style="width:100px; height:40px" id="qty-input-${response.items[0]._id}" class="qty-input" type="number" name="ec_qtybtn" value="${productData.quantity}" oninput="handleQtyInput(this, '${response._id}', '${response.items[0]._id}', true)"/>
|
||||
|
|
3
cart.php
3
cart.php
|
@ -82,6 +82,9 @@ if ($_SESSION["userId"] <> "") {
|
|||
<?php include "header.php" ?>
|
||||
<!-- Header End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- ekka Cart Start -->
|
||||
<div class="ec-side-cart-overlay"></div>
|
||||
<div id="ec-side-cart" class="ec-side-cart">
|
||||
|
|
|
@ -35,6 +35,17 @@
|
|||
<!-- Background css -->
|
||||
<link rel="stylesheet" id="bg-switcher-css" href="assets/css/backgrounds/bg-4.css">
|
||||
|
||||
<!-- 02-27-2024 Stacy added style for Sidebar Category -->
|
||||
<style>
|
||||
#sidebar-category:hover {
|
||||
background-color: #ffaa00;
|
||||
border-radius: 10px;
|
||||
color: #ffffff;
|
||||
}
|
||||
#sidebar-category:hover .ec-sidebar-block-item{
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body class="shop_page">
|
||||
|
@ -48,11 +59,14 @@
|
|||
<div class="ec-sb-title">
|
||||
<h3 class="ec-sidebar-title">Category<button class="ec-close">×</button></h3>
|
||||
</div>
|
||||
<div class="ec-sb-block-content">
|
||||
<ul>
|
||||
<!-- 02-27-2024 Stacy modified Sidebar Category Block -->
|
||||
<div class="ec-sb-block-content" id="sidebar-category">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-block-item"><img src="assets/images/icons/dress-8.png" class="svg_img" alt="drink" />Cothes</div>
|
||||
<ul style="display: block;">
|
||||
<a href="search_product_action.php?category=Electronics">
|
||||
<div class="ec-sidebar-block-item">
|
||||
<i class="fi fi-rs-headset" style="padding-right:10px; padding-top:2px;"></i>Electronics</div></a>
|
||||
<!-- <ul style="display: block;">
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">Shirt <span title="Available Stock">- 25</span></a>
|
||||
</div>
|
||||
|
@ -69,15 +83,17 @@
|
|||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">dress & frock <span title="Available Stock">- 35</span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ec-sb-block-content">
|
||||
<div class="ec-sb-block-content" id="sidebar-category">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-block-item"><img src="assets/images/icons/shoes-8.png" class="svg_img" alt="drink" />Footwear</div>
|
||||
<ul>
|
||||
<a href="search_product_action.php?category=Solar">
|
||||
<div class="ec-sidebar-block-item" id="sidebar-category-content">
|
||||
<i class="fi fi-rr-square" style="padding-right:10px; padding-top:2px;"></i>Solar</div></a>
|
||||
<!-- <ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">Sports <span title="Available Stock">- 25</span></a>
|
||||
</div>
|
||||
|
@ -94,15 +110,17 @@
|
|||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">safety shoes <span title="Available Stock">- 35</span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ec-sb-block-content">
|
||||
<div class="ec-sb-block-content" id="sidebar-category">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-block-item"><img src="assets/images/icons/jewelry-8.png" class="svg_img" alt="drink" />jewelry</div>
|
||||
<ul>
|
||||
<a href="search_product_action.php?category=E-bike">
|
||||
<div class="ec-sidebar-block-item">
|
||||
<i class="fi fi-rs-bike" style="padding-right:10px; padding-top:2px;"></i>E-Bike</div></a>
|
||||
<!-- <ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">Earrings <span title="Available Stock">- 50</span></a>
|
||||
</div>
|
||||
|
@ -115,15 +133,17 @@
|
|||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">Necklace <span title="Available Stock">- 40</span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ec-sb-block-content">
|
||||
<div class="ec-sb-block-content" id="sidebar-category">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-block-item"><img src="assets/images/icons/perfume-8.png" class="svg_img" alt="drink" />perfume</div>
|
||||
<ul>
|
||||
<a href="search_product_action.php?category=E-vehicle">
|
||||
<div class="ec-sidebar-block-item">
|
||||
<i class="fi fi-rs-car-side" style="padding-right:10px; padding-top:2px;"></i>E-Vehicle</div></a>
|
||||
<!-- <ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">Clothes perfume<span title="Available Stock">- 4 pcs</span></a>
|
||||
</div>
|
||||
|
@ -141,15 +161,17 @@
|
|||
Freshener<span title="Available Stock">- 35 pack</span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ec-sb-block-content">
|
||||
<div class="ec-sb-block-content" id="sidebar-category">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-block-item"><img src="assets/images/icons/cosmetics-8.png" class="svg_img" alt="drink" />cosmetics</div>
|
||||
<ul>
|
||||
<a href="search_product_action.php?category=Appliance">
|
||||
<div class="ec-sidebar-block-item">
|
||||
<i class="fi fi-rr-calculator" style="padding-right:10px; padding-top:2px;"></i>Appliance</div></a>
|
||||
<!-- <ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">shampoo<span title="Available Stock"></span></a>
|
||||
</div>
|
||||
|
@ -167,15 +189,17 @@
|
|||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">makeup kit<span title="Available Stock"></span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ec-sb-block-content">
|
||||
<div class="ec-sb-block-content" id="sidebar-category">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-block-item"><img src="assets/images/icons/glasses-8.png" class="svg_img" alt="drink" />glasses</div>
|
||||
<ul>
|
||||
<a href="search_product_action.php?category=Smart Home">
|
||||
<div class="ec-sidebar-block-item">
|
||||
<i class="fi fi-rs-screen" style="padding-right:10px; padding-top:2px;"></i>Smart Home</div></a>
|
||||
<!-- <ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">Sunglasses <span title="Available Stock">- 20</span></a>
|
||||
</div>
|
||||
|
@ -184,15 +208,17 @@
|
|||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">Lenses <span title="Available Stock">- 52</span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ec-sb-block-content">
|
||||
<div class="ec-sb-block-content" id="sidebar-category">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-block-item"><img src="assets/images/icons/bag-8.png" class="svg_img" alt="drink" />bags</div>
|
||||
<ul>
|
||||
<a href="search_product_action.php?category=Home">
|
||||
<div class="ec-sidebar-block-item">
|
||||
<i class="fi fi-rr-home" style="padding-right:10px; padding-top:2px;"></i>Home</div></a>
|
||||
<!-- <ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">shopping bag <span title="Available Stock">- 25</span></a>
|
||||
</div>
|
||||
|
@ -210,15 +236,119 @@
|
|||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">wallet <span title="Available Stock">- 35</span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ec-sb-block-content" id="sidebar-category">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="search_product_action.php?category=Apparell">
|
||||
<div class="ec-sidebar-block-item">
|
||||
<i class="fi fi-rr-user" style="padding-right:10px; padding-top:2px;"></i>Apparel</div></a>
|
||||
<!-- <ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">shopping bag <span title="Available Stock">- 25</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">Gym
|
||||
backpack <span title="Available Stock">- 52</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">purse <span title="Available Stock">- 40</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">wallet <span title="Available Stock">- 35</span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ec-sb-block-content" id="sidebar-category">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="search_product_action.php?category=Heavy Equipment">
|
||||
<div class="ec-sidebar-block-item">
|
||||
<i class="fi fi-rr-tool-box" style="padding-right:10px; padding-top:2px;"></i>Heavy Equipment</div></a>
|
||||
<!-- <ul>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">shopping bag <span title="Available Stock">- 25</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">Gym
|
||||
backpack <span title="Available Stock">- 52</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">purse <span title="Available Stock">- 40</span></a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="ec-sidebar-sub-item"><a href="shop-left-sidebar-col-4.php">wallet <span title="Available Stock">- 35</span></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- 02-27-2024 Stacy modified Sidebar Category Block -->
|
||||
</div>
|
||||
<!-- Sidebar Category Block -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="ec-sidebar-slider-cat">
|
||||
|
||||
<div class="ec-sidebar-slider">
|
||||
<div class="ec-sb-slider-title">Best Sellers</div>
|
||||
<div class="ec-sb-pro-sl">
|
||||
<div>
|
||||
<?php
|
||||
$productBestSellers = simpleProducts("");
|
||||
$array = array_filter($productBestSellers, function ($var) {
|
||||
return (fnmatch("Solar*", $var['product_category']) || fnmatch("E-bike*", $var['product_category'])
|
||||
|| fnmatch("Appliance*", $var['product_category']) || fnmatch("E-Vehicle*", $var['product_category'])
|
||||
|| fnmatch("Electronics*", $var['product_category']) || fnmatch("Smart Home*", $var['product_category'])
|
||||
|| fnmatch("Heavy Equipment*", $var['product_category']) || fnmatch("Home*", $var['product_category']));
|
||||
});
|
||||
$bestSellers = array_values($array);
|
||||
for ($x = 0; $x <= 3; $x++) {
|
||||
$pid = rand(0, count($bestSellers) - 1);
|
||||
?>
|
||||
<div class="ec-sb-pro-sl-item">
|
||||
<a href="product-left-sidebar.php?id=<?php echo $bestSellers[$pid]["_id"]; ?>" class="sidekka_pro_img"><img src="<?php echo $bestSellers[$pid]["product_image"] ?>" alt="product" /></a>
|
||||
<div class="ec-pro-content">
|
||||
<h5 class="ec-pro-title"><a href="product-left-sidebar.php?id=<?php echo $bestSellers[$pid]["_id"]; ?>"><?php echo $bestSellers[$pid]["product_name"] ?></a></h5>
|
||||
<!-- <div class="ec-pro-rating">
|
||||
<i class="ecicon eci-star fill"></i>
|
||||
<i class="ecicon eci-star fill"></i>
|
||||
<i class="ecicon eci-star fill"></i>
|
||||
<i class="ecicon eci-star fill"></i>
|
||||
<i class="ecicon eci-star"></i>
|
||||
</div> -->
|
||||
<span class="ec-price">
|
||||
<?php if (isset($bestSellers[$pid]["sale_price"]) && $bestSellers[$pid]["sale_price"] > 0) : ?>
|
||||
<span class="old-price">₱<?php echo number_format($bestSellers[$pid]["regular_price"], 2, ".", ",") ?></span>
|
||||
<span class="new-price">₱<?php echo number_format($bestSellers[$pid]["sale_price"], 2, ".", ",") ?></span>
|
||||
<?php elseif (isset($bestSellers[$pid]["regular_price"]) && $bestSellers[$pid]["regular_price"] != "") : ?>
|
||||
<span class="new-price">₱<?php echo number_format($bestSellers[$pid]["regular_price"], 2, ".", ",") ?></span>
|
||||
|
||||
<?php elseif ($bestSellers[$pid]["regular_price"] == "" || $bestSellers[$pid]["regular_price"] == null) : ?>
|
||||
<span class="inquire-text">Inquire</span>
|
||||
<?php else : ?>
|
||||
<span class="inquire-text">Inquire</span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="ec-sidebar-slider-cat">
|
||||
<div class="ec-sb-slider-title">Best Sellers</div>
|
||||
<div class="ec-sb-pro-sl">
|
||||
<div>
|
||||
|
@ -377,7 +507,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
426
checkouttest.php
426
checkouttest.php
|
@ -83,6 +83,8 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
<link rel="stylesheet" href="assets/css/responsive.css" />
|
||||
|
||||
<!-- Background css -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
<link rel="stylesheet" id="bg-switcher-css" href="assets/css/backgrounds/bg-4.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@latest/dist/css/select2.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
||||
|
@ -105,6 +107,13 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
#sidebar-category:hover{
|
||||
color: #ffaa00;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body onload="updateCartItemCount(); updateWishItemCount()" class="checkout_page">
|
||||
|
@ -252,19 +261,29 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#secondModal">Add New Address</button>
|
||||
|
||||
<!-- Display a list of addresses and let the user choose -->
|
||||
<form id="addressForm">
|
||||
<form id="addressForm" style="min-width: 500px;">
|
||||
<label>Select Address:</label>
|
||||
<?php foreach ($customer_data as $customer_index => $customer) { ?>
|
||||
<?php foreach ($customer['address'] as $address_index => $address) { ?>
|
||||
<div class="form-check">
|
||||
<!-- added new id for filter delete -->
|
||||
<div class="form-check" id="form-check-<?php echo $address_index ?>">
|
||||
<input type="radio" class="form-check-input" name="selectedAddress" id="address_<?php echo $customer_index; ?>_<?php echo $address_index; ?>" value="<?php echo $customer_index; ?>_<?php echo $address_index; ?>">
|
||||
<label class="form-check-label" for="address_<?php echo $customer_index; ?>_<?php echo $address_index; ?>">
|
||||
<label class="form-check-label" style="max-width: 80%; word-wrap: break-word;" for="address_<?php echo $customer_index; ?>_<?php echo $address_index; ?>">
|
||||
<?php echo $address['first_name']; ?> <?php echo $address['last_name']; ?><br>
|
||||
<?php echo $address['address_1']; ?> <?php echo $address['address_2']; ?>
|
||||
<?php echo $address['barangay']; ?>, <?php echo $address['city']; ?>,
|
||||
<?php echo $address['province']; ?> <?php echo $address['country']; ?><br>
|
||||
Phone: <?php echo $address['phone']; ?>
|
||||
</label>
|
||||
<!-- raymart added icon march 4 2024 -->
|
||||
<?php
|
||||
$address['id'] =$address_index;
|
||||
$jsonAddress = json_encode($address)?>
|
||||
<a onclick="deleteAddress('<?php echo $customer['_id']; ?>', <?php echo $address_index; ?>, true)"
|
||||
class="fa-regular fa-trash-can" id="sidebar-category" style="float: right; font-size: 20px;"></a>
|
||||
<a data-bs-toggle="modal" data-bs-target="#thirdModal" data-value=' <?php echo $jsonAddress; ?>'
|
||||
class="fa-regular fa-pen-to-square" id="sidebar-category" style="float: right; font-size: 20px; padding-right: 50px;"></a>
|
||||
<!-- raymart added icon march 4 2024 -->
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
@ -278,6 +297,50 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
<script>
|
||||
var customerData = <?php echo json_encode($customer_data); ?>;
|
||||
|
||||
// raymart/sir jun added delete function for customer id march 4 2024
|
||||
function deleteAddress(customerId, addressIndex) {
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/customers/' + customerId)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
let existingAddresses = data.address || [];
|
||||
if (addressIndex >= 0 && addressIndex < existingAddresses.length) {
|
||||
existingAddresses.splice(addressIndex, 1);
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/customers/' + customerId, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
address: existingAddresses
|
||||
}),
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
// filter the delete action
|
||||
document.getElementById('form-check-' + addressIndex).remove();
|
||||
|
||||
// location.reload();
|
||||
} else {
|
||||
console.error('Failed to submit data');
|
||||
alert('Failed to submit data');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Error submitting data');
|
||||
});
|
||||
} else {
|
||||
console.log("Invalid address index.");
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Error fetching customer data');
|
||||
});
|
||||
}
|
||||
// raymart/sir jun added delete function for customer id march 4 2024
|
||||
|
||||
|
||||
function useSelectedAddress() {
|
||||
// Get the selected address radio button
|
||||
var selectedAddress = document.querySelector('input[name="selectedAddress"]:checked');
|
||||
|
@ -355,7 +418,89 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
<input type="text" class="form-control" id="addressCountry">
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" id="submitBtn">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- raymart added 3rd modal march to show the customer address 04 2024 -->
|
||||
<div class="modal fade" id="thirdModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-sm" role="document" style="max-width: 800px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body" style="overflow-y: auto; max-height: 90vh;">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
|
||||
<label for="addressFirstName" class="text-dark font-weight-medium pt-3 mb-2">First Name</label>
|
||||
<input type="text" class="form-control" id="addressFirstName2" value="<?php echo $address['first_name']; ?>">
|
||||
|
||||
<!-- <label for="addressFirstName" class="text-dark font-weight-medium pt-3 mb-2">First Name</label>-->
|
||||
<input type="hidden" class="form-control" id="addressId" >
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<label for="addressLastName" class="text-dark font-weight-medium pt-3 mb-2">Last Name</label>
|
||||
<input type="text" class="form-control" id="addressLastName2" value="<?php echo $address['last_name']; ?>">
|
||||
<!-- <label for="addressLastName" class="text-dark font-weight-medium pt-3 mb-2">Last Name</label>
|
||||
<input type="text" class="form-control" id="addressLastName"> -->
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
<input type="text" class="form-control" id="addressContact2" value="<?php echo $address['phone']; ?>">
|
||||
|
||||
|
||||
<!-- <label for="addressContact" class="text-dark font-weight-medium pt-3 mb-2">Contact Number</label>
|
||||
<input type="number" class="form-control" id="addressContact"> -->
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<label for="addressBuilding" class="text-dark font-weight-medium pt-3 mb-2">Building,Number</label>
|
||||
<input type="text" class="form-control" id="addressBuilding2" value="<?php echo $address['address_1']; ?>">
|
||||
|
||||
<!-- <label for="addressBuilding" class="text-dark font-weight-medium pt-3 mb-2"> Building,Number </label>
|
||||
<input type="text" class="form-control" id="addressBuilding"> -->
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<label for="addressStreet" class="text-dark font-weight-medium pt-3 mb-2">Street </label>
|
||||
<input type="text" class="form-control" id="addressStreet2" value="<?php echo $address['address_2']; ?>">
|
||||
|
||||
<!-- <label for="addressStreet" class="text-dark font-weight-medium pt-3 mb-2"> Street </label>
|
||||
<input type="text" class="form-control" id="addressStreet"> -->
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<label for="provinceSelect2">Province</label>
|
||||
<select class="form-select" id="provinceSelect2">
|
||||
<option id="provinceSelect2Opt" value="<?php echo $address['province']; ?>" >Select Province</option>
|
||||
</select>
|
||||
|
||||
<!-- <label for="provinceSelect">Province</label>
|
||||
<select class="form-select" id="provinceSelect">
|
||||
<option value="" disabled selected hidden>Select Province</option>
|
||||
</select> -->
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="citySelect2">Municipality/City</label>
|
||||
<select class="form-select" id="citySelect2" required>
|
||||
<option value="" id="citySelect2Opt" selected hidden>Select Municipality/City</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="barangaySelect2">Barangay</label>
|
||||
<select class="form-select" id="barangaySelect2" required>
|
||||
<option value="" id="barangaySelect2Opt" selected hidden>Select Barangay</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="addressCountry2" class="text-dark font-weight-medium pt-3 mb-2">Country</label>
|
||||
<input type="text" class="form-control" id="addressCountry2">
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" id="submitBtn2">Submit</button>
|
||||
<!-- raymart added 3rd modal march to show the customer address 04 2024 -->
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
@ -363,8 +508,163 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const customerId = '<?php echo $customerId ?>';
|
||||
<script>
|
||||
// raymart/sir mark added function to show the addresses of the customer in the third modal march 04 2024
|
||||
$('#thirdModal').on('shown.bs.modal', function (event) {
|
||||
|
||||
var jsonString = $(event.relatedTarget).data('value');
|
||||
|
||||
var jsonObject = JSON.parse(jsonString);
|
||||
console.log(jsonObject)
|
||||
|
||||
// document.getElementById("addressFirstName2").value('mmmm');
|
||||
// $('#addressFirstName2').setAttribute('value','My default value');
|
||||
document.querySelector('input[id="addressFirstName2"]').value = jsonObject.first_name;
|
||||
document.querySelector('input[id="addressLastName2"]').value = jsonObject.last_name;
|
||||
document.querySelector('input[id="addressContact2"]').value = jsonObject.phone;
|
||||
document.querySelector('input[id="addressBuilding2"]').value = jsonObject.address_1;
|
||||
document.querySelector('input[id="addressStreet2"]').value = jsonObject.address_2;
|
||||
document.querySelector('option[id="provinceSelect2Opt"]').text = jsonObject.province;
|
||||
document.querySelector('option[id="provinceSelect2Opt"]').value = jsonObject.province;
|
||||
|
||||
document.querySelector('option[id="citySelect2Opt"]').text = jsonObject.city;
|
||||
document.querySelector('option[id="citySelect2Opt"]').value = jsonObject.city;
|
||||
|
||||
document.querySelector('option[id="barangaySelect2Opt"]').text = jsonObject.barangay;
|
||||
document.querySelector('option[id="barangaySelect2Opt"]').value = jsonObject.barangay;
|
||||
|
||||
document.querySelector('input[id="addressCountry2"]').value = jsonObject.country;
|
||||
document.querySelector('input[id="addressId"]').value = jsonObject.id;
|
||||
|
||||
|
||||
|
||||
console.log('id ' + jsonObject.id)
|
||||
const provinceSelect = $('#provinceSelect2'); // Use jQuery to select the element
|
||||
const citySelect = $('#citySelect2'); // Use jQuery to select the element
|
||||
const barangaySelect = $('#barangaySelect2'); // Use jQuery to select the element
|
||||
|
||||
// const provinceSelect = $('#provinceSelect2'); // Use jQuery to select the element
|
||||
// const citySelect = $('#citySelect2'); // Use jQuery to select the element
|
||||
// const barangaySelect = $('#barangaySelect2'); // Use jQuery to select the element
|
||||
|
||||
// Initialize Select2 on the provinceSelect, citySelect, and barangaySelect elements
|
||||
provinceSelect.select2({
|
||||
dropdownParent: $('#thirdModal'),
|
||||
containerCssClass: 'select2-zindex-high' // Optional, add a custom class for styling
|
||||
});
|
||||
|
||||
citySelect.select2({
|
||||
dropdownParent: $('#thirdModal'),
|
||||
containerCssClass: 'select2-zindex-high' // Optional, add a custom class for styling
|
||||
});
|
||||
barangaySelect.select2({
|
||||
dropdownParent: $('#thirdModal'),
|
||||
containerCssClass: 'select2-zindex-high' // Optional, add a custom class for styling
|
||||
});
|
||||
|
||||
// Fetch provinces data
|
||||
fetch('https://psgc.gitlab.io/api/provinces')
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
console.error('Failed to fetch provinces');
|
||||
throw new Error('Failed to fetch provinces');
|
||||
}
|
||||
})
|
||||
.then(provincesData => {
|
||||
// Iterate through the provinces data and add options
|
||||
provincesData.forEach(province => {
|
||||
const option = new Option(province.name, province.code);
|
||||
provinceSelect.append(option);
|
||||
});
|
||||
|
||||
// Add an extra option manually
|
||||
const extraOption = new Option('Metro Manila', '130000000');
|
||||
provinceSelect.append(extraOption);
|
||||
|
||||
// Add event listener to provinceSelect
|
||||
provinceSelect.on('change', function() {
|
||||
// Clear existing options in citySelect and barangaySelect
|
||||
citySelect.html('<option value="" disabled selected hidden>Select City</option>');
|
||||
barangaySelect.html('<option value="" disabled selected hidden>Select Barangay</option>');
|
||||
|
||||
// Fetch and update cities/municipalities based on the selected province
|
||||
updateCities();
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
|
||||
// Function to update city/municipality options based on the selected province
|
||||
function updateCities() {
|
||||
const selectedProvinceCode = provinceSelect.val(); // Use val() to get the selected value with Select2
|
||||
if (selectedProvinceCode) {
|
||||
let citiesEndpoint;
|
||||
if (selectedProvinceCode === '130000000') {
|
||||
// Check if Metro Manila is selected
|
||||
citiesEndpoint = 'https://psgc.gitlab.io/api/regions/130000000/cities-municipalities/';
|
||||
} else {
|
||||
citiesEndpoint = `https://psgc.gitlab.io/api/provinces/${selectedProvinceCode}/cities-municipalities/`;
|
||||
}
|
||||
|
||||
fetch(citiesEndpoint)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
console.error('Failed to fetch cities/municipalities');
|
||||
throw new Error('Failed to fetch cities/municipalities');
|
||||
}
|
||||
})
|
||||
.then(citiesData => {
|
||||
// Iterate through the cities data and add options
|
||||
citiesData.forEach(city => {
|
||||
const option = new Option(city.name, city.code);
|
||||
citySelect.append(option);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Add event listener to citySelect
|
||||
citySelect.on('change', function() {
|
||||
// Clear existing options in barangaySelect
|
||||
barangaySelect.html('<option value="" disabled selected hidden>Select Barangay</option>');
|
||||
|
||||
// Fetch and update barangays based on the selected city/municipality
|
||||
const selectedCityCode = citySelect.val();
|
||||
if (selectedCityCode) {
|
||||
fetch(`https://psgc.gitlab.io/api/cities-municipalities/${selectedCityCode}/barangays/`)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
console.error('Failed to fetch barangays');
|
||||
throw new Error('Failed to fetch barangays');
|
||||
}
|
||||
})
|
||||
.then(barangaysData => {
|
||||
// Iterate through the barangays data and add options
|
||||
barangaysData.forEach(barangay => {
|
||||
const option = new Option(barangay.name, barangay.code);
|
||||
barangaySelect.append(option);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// document.querySelector('input[id="addressFirstName2"]').value = jsonObject.last_name;
|
||||
});
|
||||
// raymart/sir mark added function to show the addresses of the customer in the third modal march 04 2024
|
||||
const customerId = '<?php echo $customerId ?>';
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Get the select elements
|
||||
const provinceSelect = $('#provinceSelect'); // Use jQuery to select the element
|
||||
|
@ -552,6 +852,90 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
// raymart/sir mark added submitbtn2 for edited customerId march 04 2024
|
||||
$('#submitBtn2').on('click', function() {
|
||||
// function updateAddress(){
|
||||
// Retrieve existing addresses from the API
|
||||
// fetch('https://api.obanana.shop/api/v1/customers/65482e8d209ff8d348bd30fd')
|
||||
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/customers/' + customerId)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
// Get the existing addresses array
|
||||
const existingAddresses = data.address || [];
|
||||
|
||||
// Get the new address details
|
||||
const firstName = $('#addressFirstName2').val();
|
||||
const lastName = $('#addressLastName2').val();
|
||||
const contact = $('#addressContact2').val();
|
||||
const buildingNumber = $('#addressBuilding2').val();
|
||||
const street = $('#addressStreet2').val();
|
||||
const province = $('#provinceSelect2 :selected').text();
|
||||
const city = $('#citySelect2 :selected').text();
|
||||
const barangay = $('#barangaySelect2 :selected').text();
|
||||
const country = $('#addressCountry2').val();
|
||||
const id = $('#addressId').val();
|
||||
console.log('clickkkkkkkk'+ id)
|
||||
|
||||
|
||||
// Create a new address object
|
||||
const newAddress = {
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
phone: contact,
|
||||
address_1: buildingNumber,
|
||||
address_2: street,
|
||||
city: city,
|
||||
province: province,
|
||||
barangay: barangay,
|
||||
country: country,
|
||||
};
|
||||
|
||||
// Add the new address to the existing addresses
|
||||
// existingAddresses.push(newAddress);
|
||||
|
||||
// var newAddresses= existingAddresses.filter((e,i)=>i!==id)
|
||||
let existingAddress = existingAddresses
|
||||
|
||||
existingAddress[id]={
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
phone: contact,
|
||||
address_1: buildingNumber,
|
||||
address_2: street,
|
||||
city: city,
|
||||
province: province,
|
||||
barangay: barangay,
|
||||
country: country,
|
||||
};
|
||||
console.log( existingAddress[id])
|
||||
// Make a PATCH request to update the addresses array
|
||||
return fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/customers/' + customerId, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
address: existingAddress
|
||||
}),
|
||||
});
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
// Handle success (e.g., show a success message)
|
||||
location.reload();
|
||||
} else {
|
||||
// Handle error
|
||||
console.error('Failed to submit data');
|
||||
alert('Failed to submit data');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
// Handle network or other errors
|
||||
console.error('Error:', error);
|
||||
alert('Error submitting data');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
@ -1021,19 +1405,29 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
console.log(orderId)
|
||||
const token = '<?php echo $_SESSION["token"] ?>';
|
||||
const shippingfee = parseFloat(orderId.shipping_fee)
|
||||
|
||||
const orderProductId = orderId.items[0].product.product_id;
|
||||
const productResponse = await fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/products/${orderProductId}`);
|
||||
const productData = await productResponse.json();
|
||||
let freeShippingCod = false;
|
||||
if (productData.promo && productData.promo.length > 0 && productData.promo[0]['free-shipping'] === 'Yes') {
|
||||
freeShippingCod = true;
|
||||
}
|
||||
|
||||
const shippingFees = freeShippingCod ? 0 : shippingfee;
|
||||
const patchResponse = await fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders/${orderId._id}`, {
|
||||
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,
|
||||
|
@ -1050,7 +1444,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
status: "UNPAID",
|
||||
reference_number: uniqueRef,
|
||||
},
|
||||
total_amount: parseFloat(orderId.total_amount) + shippingfee,
|
||||
total_amount: parseFloat(orderId.total_amount) + shippingFees,
|
||||
status: "TO PAY",
|
||||
order_date: iso8601String,
|
||||
payment_method: "Cash On Delivery",
|
||||
|
@ -1060,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}`);
|
||||
}
|
||||
|
|
76
index.php
76
index.php
|
@ -254,8 +254,23 @@ if ($_SESSION["userId"] <> "") {
|
|||
<!-- <span class="percentage">20%</span> -->
|
||||
<!-- raymart edit action -->
|
||||
<div class="ec-pro-actions" style="bottom: -36px;">
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
<!-- 02-29-2024 Stacy disabling hover add to cart if there's no price -->
|
||||
<?php if (isset($forAll[$pid]["sale_price"]) && $forAll[$pid]["sale_price"] > 0) : ?>
|
||||
<button title="Add To Cart" style="display:none;" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php elseif (isset($forAll[$pid]["regular_price"]) && $forAll[$pid]["regular_price"] != "") : ?>
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php else : ($forAll[$pid]["regular_price"] == "" || $forAll[$pid]["regular_price"] == null) ?>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php endif; ?>
|
||||
<!-- 02-29-2024 Stacy disabling hover add to cart if there's no price -->
|
||||
|
||||
<!-- <button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a> -->
|
||||
</div>
|
||||
<!-- <div class="ec-pro-actions">
|
||||
<button title="Add To Cart" onclick="popupAddToCart('<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>','<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>', '<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>' , '<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>' , '<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>' ,'<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
|
@ -360,8 +375,23 @@ if ($_SESSION["userId"] <> "") {
|
|||
|
||||
<!-- raymart edit action feb 14 2024-->
|
||||
<div class="ec-pro-actions" style="bottom: -36px;">
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($electronics[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($electronics[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
<!-- 02-29-2024 Stacy disabling hover add to cart if there's no price -->
|
||||
<?php if (isset($electronics[$pid]["sale_price"]) && $electronics[$pid]["sale_price"] > 0) : ?>
|
||||
<button title="Add To Cart" style="display:none;" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($electronics[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($electronics[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php elseif (isset($electronics[$pid]["regular_price"]) && $electronics[$pid]["regular_price"] != "") : ?>
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($electronics[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($electronics[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php else : ($electronics[$pid]["regular_price"] == "" || $electronics[$pid]["regular_price"] == null) ?>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($electronics[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php endif; ?>
|
||||
<!-- 02-29-2024 Stacy disabling hover add to cart if there's no price -->
|
||||
|
||||
<!-- <button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($electronics[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($electronics[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a> -->
|
||||
</div>
|
||||
<!-- <div class="ec-pro-actions">
|
||||
<button title="Add To Cart" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
|
@ -466,8 +496,23 @@ if ($_SESSION["userId"] <> "") {
|
|||
<!-- <span class="percentage">20%</span> -->
|
||||
<!-- raymart edit action feb 14 2024-->
|
||||
<div class="ec-pro-actions"style="bottom: -36px;">
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($smartHome[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($smartHome[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
<!-- 02-29-2024 Stacy disabling hover add to cart if there's no price -->
|
||||
<?php if (isset($smartHome[$pid]["sale_price"]) && $smartHome[$pid]["sale_price"] > 0) : ?>
|
||||
<button title="Add To Cart" style="display:none;" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($smartHome[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($smartHome[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php elseif (isset($smartHome[$pid]["regular_price"]) && $smartHome[$pid]["regular_price"] != "") : ?>
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($smartHome[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($smartHome[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php else : ($smartHome[$pid]["regular_price"] == "" || $smartHome[$pid]["regular_price"] == null) ?>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($smartHome[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php endif; ?>
|
||||
<!-- 02-29-2024 Stacy disabling hover add to cart if there's no price -->
|
||||
|
||||
<!-- <button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($smartHome[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($smartHome[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a> -->
|
||||
</div>
|
||||
<!-- <div class="ec-pro-actions">
|
||||
<button title="Add To Cart" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
|
@ -571,8 +616,23 @@ if ($_SESSION["userId"] <> "") {
|
|||
<!-- <span class="percentage">20%</span> -->
|
||||
<!-- raymart added action feb 14 2024-->
|
||||
<div class="ec-pro-actions"style="bottom: -36px;">
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($forVehicle[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forVehicle[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
<!-- 02-29-2024 Stacy disabling hover add to cart if there's no price -->
|
||||
<?php if (isset($forVehicle[$pid]["sale_price"]) && $forVehicle[$pid]["sale_price"] > 0) : ?>
|
||||
<button title="Add To Cart" style="display:none;" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($forVehicle[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forVehicle[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php elseif (isset($forVehicle[$pid]["regular_price"]) && $forVehicle[$pid]["regular_price"] != "") : ?>
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($forVehicle[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forVehicle[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php else : ($forVehicle[$pid]["regular_price"] == "" || $forVehicle[$pid]["regular_price"] == null) ?>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forVehicle[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
|
||||
<?php endif; ?>
|
||||
<!-- 02-29-2024 Stacy disabling hover add to cart if there's no price -->
|
||||
|
||||
<!-- <button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($forVehicle[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forVehicle[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a> -->
|
||||
</div>
|
||||
<!-- <div class="ec-pro-actions">
|
||||
<button title="Add To Cart" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
|
|
|
@ -86,6 +86,9 @@ if ($_SESSION["userId"] <> "") {
|
|||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Ec breadcrumb start -->
|
||||
<div class="sticky-header-next-sec ec-breadcrumb section-space-mb">
|
||||
<div class="container">
|
||||
|
|
|
@ -236,6 +236,10 @@ if (isset($_GET['id'])) {
|
|||
<!-- ekka Cart Start -->
|
||||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Ec breadcrumb start -->
|
||||
<div class="sticky-header-next-sec ec-breadcrumb section-space-mb">
|
||||
<div class="container">
|
||||
|
|
|
@ -102,6 +102,8 @@ if ($_SESSION["userId"] <> "") {
|
|||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Page detail section -->
|
||||
<!-- Main Slider Start -->
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -307,6 +307,8 @@ if (!empty($_GET['minPrice']) || !empty($_GET['maxPrice']) || !empty($_GET['cate
|
|||
|
||||
for ($x = $startIndex; $x <= $endIndex; $x++) {
|
||||
$product = $filteredProducts[$x]['product'];
|
||||
$productWithoutSpecs = $product;
|
||||
unset($productWithoutSpecs['specifications']);
|
||||
$vendorOfProduct = getVendorbyId($product['vendor_api_id']);
|
||||
// $product_image = !empty($product["product_image"]) ? $product["product_image"] : "https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/No-Image-Placeholder.svg/330px-No-Image-Placeholder.svg.png";
|
||||
$sale_price = isset($product['sale_price']) ? $product['sale_price'] : null;
|
||||
|
@ -338,8 +340,8 @@ if (!empty($_GET['minPrice']) || !empty($_GET['maxPrice']) || !empty($_GET['cate
|
|||
<img class="hover-image" src="<?php echo $product_image ?>" alt="Product" />
|
||||
</a> -->
|
||||
<div class="ec-pro-actions">
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($forAll[$pid]), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
<button title="Add To Cart" onclick="popupAddToCart(`<?php echo htmlspecialchars(json_encode($productWithoutSpecs), ENT_QUOTES, 'UTF-8'); ?>`,`<?php echo htmlspecialchars($vendorOfProduct, ENT_QUOTES, 'UTF-8'); ?>`, `<?php echo isset($_SESSION['token']) ? $_SESSION['token'] : ''; ?>` , `<?php echo isset($_SESSION['email']) ? $_SESSION['email'] : ''; ?>` , `<?php echo isset($_SESSION['password']) ? $_SESSION['password'] : ''; ?>` , `<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>`);" class="add-to-cart"><i class="fi-rr-shopping-basket"></i> Add To Cart</button>
|
||||
<a class="ec-btn-group wishlist" title="Wishlist" onclick="popupWishlist('<?php echo htmlspecialchars(json_encode($productWithoutSpecs), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(json_encode($customer_data), ENT_QUOTES, 'UTF-8'); ?>');"><i class="fi-rr-heart"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -92,6 +92,9 @@ if ($_SESSION["userId"] <> "") {
|
|||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Ec breadcrumb start -->
|
||||
<div class="sticky-header-next-sec ec-breadcrumb section-space-mb">
|
||||
<div class="container">
|
||||
|
@ -360,7 +363,9 @@ if ($_SESSION["userId"] <> "") {
|
|||
<?php
|
||||
if ($order['return_order']['status'] === 'To Approve') {
|
||||
echo '<span class="tbl-btn">Refund Requested</span>';
|
||||
} else {
|
||||
} 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>';
|
||||
}
|
||||
?>
|
||||
|
@ -380,7 +385,6 @@ if ($_SESSION["userId"] <> "") {
|
|||
<i class="mdi mdi-close"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body pt-0">
|
||||
<form enctype="multipart/form-data" method="POST">
|
||||
<div class="form-group">
|
||||
|
@ -403,9 +407,9 @@ if ($_SESSION["userId"] <> "") {
|
|||
</form>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font/css/materialdesignicons.min.css">
|
||||
<script>
|
||||
var sessionToken = '<?php echo isset($_SESSION["token"]) ? $_SESSION["token"] : ""; ?>';
|
||||
var email = '<?php echo isset($_SESSION["email"]) ? $_SESSION["email"] : ""; ?>';
|
||||
var password = '<?php echo isset($_SESSION["password"]) ? $_SESSION["password"] : ""; ?>';
|
||||
var sessionToken = `<?php echo isset($_SESSION["token"]) ? $_SESSION["token"] : ""; ?>`;
|
||||
var email = `<?php echo isset($_SESSION["email"]) ? $_SESSION["email"] : ""; ?>`;
|
||||
var password = `<?php echo isset($_SESSION["password"]) ? $_SESSION["password"] : ""; ?>`;
|
||||
|
||||
function login(username, password, callback) {
|
||||
fetch("https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/login", {
|
||||
|
@ -473,16 +477,19 @@ if ($_SESSION["userId"] <> "") {
|
|||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.getElementById('submit-button-<?php echo $order['_id']; ?>').addEventListener('click', function(event) {
|
||||
login(email, password, function(token) {
|
||||
event.preventDefault();
|
||||
|
||||
// Get the order ID and reason
|
||||
var orderId = '<?php echo $order['_id']; ?>';
|
||||
event.preventDefault();
|
||||
var orderId = '<?php echo $order['_id']; ?>';
|
||||
var reason = document.getElementById('reason-' + orderId).value;
|
||||
|
||||
console.log('Order ID:', orderId);
|
||||
console.log('Reason:', reason);
|
||||
|
||||
login(email, password, function(sessionToken) {
|
||||
|
||||
|
||||
// Get the order ID and reason
|
||||
|
||||
|
||||
// Upload image
|
||||
|
||||
var fileInput = document.getElementById('image-' + orderId);
|
||||
|
@ -516,15 +523,7 @@ if ($_SESSION["userId"] <> "") {
|
|||
.then(data => {
|
||||
console.log('Upload response:', data);
|
||||
const filename = data.filename;
|
||||
// Update the order with the returned filename and other details
|
||||
// var imageUrl = 'https://api.obanana.shop/images/storage/vendor_uploads/' + data.filename;
|
||||
// var orderUpdate = {
|
||||
// return_order: {
|
||||
// reason: reason,
|
||||
// image: imageUrl,
|
||||
// status: 'To Approve',
|
||||
// },
|
||||
// };
|
||||
|
||||
const payload = {
|
||||
return_order: {
|
||||
reason: reason,
|
||||
|
@ -537,7 +536,7 @@ if ($_SESSION["userId"] <> "") {
|
|||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + token,
|
||||
'Authorization': 'Bearer ' + sessionToken,
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
|
|
@ -105,6 +105,9 @@ if ($_SESSION["userId"] <> "") {
|
|||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Ec breadcrumb start -->
|
||||
<div class="sticky-header-next-sec ec-breadcrumb section-space-mb">
|
||||
<div class="container">
|
||||
|
|
|
@ -94,6 +94,9 @@ if ($_SESSION["userId"] <> "") {
|
|||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Ec breadcrumb start -->
|
||||
<div class="sticky-header-next-sec ec-breadcrumb section-space-mb">
|
||||
<div class="container">
|
||||
|
|
|
@ -64,6 +64,8 @@ $products = productList();
|
|||
|
||||
<!-- Background css -->
|
||||
<link rel="stylesheet" id="bg-switcher-css" href="assets/css/backgrounds/bg-4.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
</head>
|
||||
|
||||
<body class="shop_page">
|
||||
|
@ -138,9 +140,12 @@ $products = productList();
|
|||
<div class="ec-vendor-dashboard-card space-bottom-30">
|
||||
<div class="ec-vendor-card-header">
|
||||
<h5>Product List</h5>
|
||||
<div class="ec-header-btn">
|
||||
<div class="ec-header-btn" >
|
||||
<!-- <a class="btn btn-lg btn-primary" href="vendor-uploads-add-product-action.php">Add</a> -->
|
||||
<a class="btn btn-lg btn-primary" onclick="addProduct();" href="">Add</a>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ec-vendor-card-body">
|
||||
|
@ -166,8 +171,10 @@ $products = productList();
|
|||
for ($i = 0; $i <= $totalProducts - 1; $i++) {
|
||||
$product = $products[$i];
|
||||
?>
|
||||
<tr>
|
||||
<tr id="<?php echo $product['_id']; ?>">
|
||||
|
||||
<td>
|
||||
|
||||
<!-- raymart added function feb 21 2024 -->
|
||||
<?php
|
||||
if (isset($product['images'])) {
|
||||
|
@ -197,12 +204,15 @@ $products = productList();
|
|||
<td><span><?php echo $product['sale_price']; ?></span></td>
|
||||
<td><span><?php echo $product['minimum_order']; ?></span></td>
|
||||
<td><span><?php echo $product['stock']; ?></span></td>
|
||||
<td style="display: flex; justify-content: space-between;">
|
||||
<span onclick="editProduct('<?php echo $product['_id'] ?>');">
|
||||
<i class="mdi mdi-circle-edit-outline"></i>
|
||||
<td style="display: flex; justify-content: space-around;">
|
||||
<span>
|
||||
<input type="checkbox" name="product_checkbox[]" style="width: 20px; height: 33px; " value="<?php echo $product['_id']; ?>">
|
||||
</span>
|
||||
<span onclick="editProduct('<?php echo $product['_id'] ?>');">
|
||||
<a class="mdi mdi-circle-edit-outline" style="font-size: 20px;"></a>
|
||||
</span>
|
||||
<span onclick="deleteProduct('<?php echo $product['_id'] ?>');">
|
||||
<i class="mdi mdi mdi-delete-outline"></i>
|
||||
<a class="mdi mdi mdi-delete-outline" style="font-size: 20px;"></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -223,6 +233,7 @@ $products = productList();
|
|||
var email = '<?php echo isset($_SESSION["email"]) ? $_SESSION["email"] : ""; ?>';
|
||||
var password = '<?php echo isset($_SESSION["password"]) ? $_SESSION["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://<?php echo $_SESSION['data_endpoint']; ?>/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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</section>
|
||||
<!-- End Vendor dashboard section -->
|
||||
|
|
|
@ -88,6 +88,9 @@ if (is_array($vendorOrderss)) {
|
|||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Ec breadcrumb start -->
|
||||
<div class="sticky-header-next-sec ec-breadcrumb section-space-mb">
|
||||
<div class="container">
|
||||
|
|
|
@ -81,6 +81,9 @@ if ($_SESSION["userId"] <> "") {
|
|||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Ec breadcrumb start -->
|
||||
<div class="sticky-header-next-sec ec-breadcrumb section-space-mb">
|
||||
<div class="container">
|
||||
|
|
|
@ -79,6 +79,9 @@ $array = json_decode($result, true);
|
|||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Ec breadcrumb start -->
|
||||
<div class="sticky-header-next-sec ec-breadcrumb section-space-mb">
|
||||
<div class="container">
|
||||
|
|
|
@ -116,12 +116,12 @@ if ($_SESSION["userId"] <> "") {
|
|||
<?php include "header.php" ?>
|
||||
<!-- Header End -->
|
||||
|
||||
|
||||
<!-- ekka Cart Start -->
|
||||
|
||||
|
||||
<!-- ekka Cart End -->
|
||||
|
||||
<!-- Category Sidebar start -->
|
||||
<?php include "category-slider.php" ?>
|
||||
|
||||
<!-- Ec breadcrumb start -->
|
||||
<div class="sticky-header-next-sec ec-breadcrumb section-space-mb">
|
||||
|
|
Loading…
Reference in New Issue