This commit is contained in:
jouls 2024-04-23 09:31:13 +08:00
commit c3c8d36238
14 changed files with 442 additions and 94 deletions

View File

@ -183,7 +183,7 @@
</section>
<!-- ec testmonial Start -->
<section class="section ec-test-section section-space-ptb-100 section-space-m" id="reviews">
<!-- <section class="section ec-test-section section-space-ptb-100 section-space-m" id="reviews">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
@ -270,11 +270,11 @@
</div>
</div>
</div>
</section>
</section> -->
<!-- ec testmonial end -->
<!-- services Section Start -->
<section class="section ec-services-section section-space-p" id="services">
<!-- <section class="section ec-services-section section-space-p" id="services">
<h2 class="d-none">Services</h2>
<div class="container">
<div class="row">
@ -324,7 +324,7 @@
</div>
</div>
</div>
</section>
</section> -->
<!--services Section End -->
<!-- Ec Instagram Start -->
@ -437,7 +437,7 @@
<!-- Footer navigation panel for responsive display end -->
<!-- Recent Purchase Popup -->
<div class="recent-purchase">
<!-- <div class="recent-purchase">
<img src="assets/images/product-image/1.jpg" alt="payment image">
<div class="detail">
<p>Someone in new just bought</p>
@ -445,7 +445,7 @@
<p>10 Minutes ago</p>
</div>
<a href="javascript:void(0)" class="icon-btn recent-close">×</a>
</div>
</div> -->
<!-- Recent Purchase Popup end -->
<!-- Cart Floating Button -->

View File

@ -31,7 +31,8 @@ if ($_SESSION["isLoggedIn"] == true and $_SESSION["user_type"] == "admin"){
<link id="ekka-css" href="assets/css/ekka.css" rel="stylesheet" />
<!-- FAVICON -->
<link href="assets/img/favicon.png" rel="shortcut icon" />
<!-- <link href="assets/img/favicon.png" rel="shortcut icon" /> -->
<link href="assets/img/favicon/favicon.png" rel="shortcut icon" />
</head>

View File

@ -46,7 +46,8 @@ $allorders = json_encode($orders, true);
<link id="ekka-css" rel="stylesheet" href="assets/css/ekka.css" />
<!-- FAVICON -->
<link href="assets/img/favicon.png" rel="shortcut icon" />
<!-- <link href="assets/img/favicon.png" rel="shortcut icon" /> -->
<link href="assets/img/favicon/favicon.png" rel="shortcut icon" />
</head>
<body class="ec-header-fixed ec-sidebar-fixed ec-sidebar-dark ec-header-light" id="body">

View File

@ -190,7 +190,61 @@ if($_SESSION["user_type"]!="admin"){
const array = new Array(productData)
console.log(array)
// const parseJs =JSON.parse(productData)
function searchProduct(e){
function searchProduct(e) {
const searchInput = document.getElementById('searchProduct');
const productWrap = document.getElementById('productWrap');
// Clear previous search results
productWrap.innerHTML = '';
// Get search query and ensure it's lowercase
const query = searchInput.value.trim().toLowerCase();
// Filter products based on search query
const filteredProducts = array[0].filter(product => {
return product.product_name.toLowerCase().includes(query);
});
if (filteredProducts.length > 0) {
// Display filtered products
filteredProducts.forEach(prod => {
const productImage = prod.images.split(',') ?? [];
const image = productImage[0] ?
`<img class="img-fluid" src="${productImage[0]}" alt="product image" style="object-fit: cover; width: 100%; height: 100%;" />` :
`<img class="img-fluid rounded-circle" src="https://api.obanana.com/images/storage/web_images/1710214273217-no_image.png" alt="placeholder image" style="object-fit: cover; width: 100%; height: 100%;" />`;
const card = document.createElement('div');
card.classList.add('col-lg-3', 'col-md-4', 'col-sm-6');
card.innerHTML = `
<div class="card-wrapper">
<div class="card-container">
<div class="card-top">
<div class="image-container" style="height: 300px;">
${image}
</div>
</div>
<div class="card-bottom">
<h3>${prod.product_name}</h3>
<p>${prod.regular_price}</p>
</div>
<div class="card-action">
<div class="card-edit" onclick="editProduct('${prod._id}');"><i class="mdi mdi-circle-edit-outline"></i></div>
<div class="card-preview"><i class="mdi mdi-eye-outline"></i></div>
<div class="card-remove" onclick="deleteProduct('${prod._id}');"><i class="mdi mdi mdi-delete-outline"></i></div>
</div>
</div>
</div>
`;
productWrap.appendChild(card);
});
} else {
// Display message if no products found
productWrap.innerHTML = `<p style="padding-top:10px; padding-left:20px;">No Product Found.</p>`;
}
}
const search = document.getElementById('searchProduct');
search.addEventListener("input", searchProduct);
/* function searchProduct(e){
const searchInput = document.getElementById('searchProduct')
let search = []
@ -255,7 +309,7 @@ if($_SESSION["user_type"]!="admin"){
// console.log(search)
}
const search = document.getElementById('searchProduct')
search.addEventListener("input", searchProduct)
search.addEventListener("input", searchProduct) */
</script>
<!-- 3-18-24 raymart add function for search bar -->
<!-- <div class="row">

View File

@ -1249,6 +1249,29 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
let itemNames = [];
submitButton.addEventListener('click', async function() {
if (pay1RadioButton.checked) {
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;
}
try {
<?php foreach ($cartItems as $checkout) { ?>
<?php foreach ($checkout['items'] as $item) { ?>
@ -1348,16 +1371,24 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
const newArray = Object.values(ordersToUpdate)
console.log(newArray)
const refchar = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let uniqueRef = '';
for (let i = 0; i < 8; i++) {
const randomIndex = Math.floor(Math.random() * refchar.length);
uniqueRef += refchar.charAt(randomIndex);
}
// let uniqueRef = '';
// for (let i = 0; i < 8; i++) {
// const randomIndex = Math.floor(Math.random() * refchar.length);
// uniqueRef += refchar.charAt(randomIndex);
// }
newArray.forEach(async (orderId) => {
console.log(orderId)
const token = '<?php echo $_SESSION["token"] ?>';
const shippingfee = parseFloat(orderId.shipping_fee)
const patchResponse = await fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders/${orderId._id}`, {
const orderPay2ProductId = orderId.items[0].product.product_id;
const productPay2Response = await fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/products/${orderPay2ProductId}`);
const productPay2Data = await productPay2Response.json();
let freeShippingObPay = false;
if (productPay2Data.promo && productPay2Data.promo.length > 0 && productPay2Data.promo[0]['free-shipping'] === 'Yes') {
freeShippingObPay = true;
}
const shippingFeesPay2 = freeShippingObPay ? 0 : shippingfee;
const patchResponse2 = await fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders/${orderId._id}`, {
method: "PATCH",
body: JSON.stringify({
shipping_address: {
@ -1386,7 +1417,8 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
status: "UNPAID",
reference_number: result.attributes.reference_number,
},
total_amount: parseFloat(orderId.total_amount) + shippingfee,
shipping_fee: shippingFeesPay2,
total_amount: parseFloat(orderId.total_amount) + shippingFeesPay2,
order_date: iso8601String,
payment_method: "Obananapay",
}),
@ -1396,12 +1428,12 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
},
});
if (!patchResponse.ok) {
throw new Error(`Error updating payment status: ${patchResponse.status} ${patchResponse.statusText}`);
if (!patchResponse2.ok) {
throw new Error(`Error updating payment status: ${patchResponse2.status} ${patchResponse2.statusText}`);
}
})
console.log("Payment Successfull")
window.location.href = 'user-history.php';
// window.location.href = 'user-history.php';
// console.log( <?php echo $filteredIdsJSON; ?>);
}
window.location.href = result.attributes.checkout_url;
@ -1492,6 +1524,7 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
},
total_amount: parseFloat(orderId.total_amount) + shippingFees,
status: "TO PAY",
shipping_fee: shippingFees,
order_date: iso8601String,
payment_method: "Cash On Delivery",
}),
@ -2171,4 +2204,4 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
</body>
</html>
</html>

View File

@ -274,6 +274,35 @@ function productListVendor($vendorId)
return $json; // Add this line to return the decoded JSON data
}
function allProductListVendor($vendorId)
{
$curl = curl_init();
$url = "https://" . $_SESSION["data_endpoint"] . "/api/v1/products/vendor/" . $vendorId;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt_array($curl, array(
//CURLOPT_URL => 'https://".$_SESSION["data_endpoint"]."/api/v1/products/vendor/6527b593f79b5deac5ad6cb8',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-Api-Key: {{apiKey}}'
),
));
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response, true);
$products = array_filter($json, function ($var) {
return ($var['product_type'] == '' || $var['product_type'] == 'simple' || $var['product_type'] == 'variable' || $var['product_type'] == 'variation');
});
$products = array_values($products);
return $products;
return $json; // Add this line to return the decoded JSON data
}
function getProductVariations($parent_id)
{
$curl = curl_init();

View File

@ -140,6 +140,8 @@ if ($_SESSION["userId"] <> "") {
line-height: 1;
}
</style>
<!--Ec Header Top Start -->
<div class="header-top">
<div class="container">
@ -180,6 +182,7 @@ if ($_SESSION["userId"] <> "") {
<?php } ?>
</div>
<script>
function displayPopup() {
// Show the pop-up
@ -205,6 +208,7 @@ if ($_SESSION["userId"] <> "") {
}
</script>
<!-- Newsletter Modal Start -->
<div id="ec-popnews-bg2"></div>
<div id="ec-popnews-box2">
@ -308,6 +312,7 @@ if ($_SESSION["userId"] <> "") {
</div>
</div>
<!-- Ec Header Top End -->
<!-- Ec Header Bottom Start -->
<div class="ec-header-bottom d-none d-lg-block">
<div class="container position-relative">
@ -428,19 +433,30 @@ if ($_SESSION["userId"] <> "") {
</a>
<div class="ec-pro-content">
<a href="product-left-sidebar.php?id=<?php echo $order['items'][0]['product']['product_id']; ?>" class="cart_pro_title"><?php echo $order['items'][0]['product']['name']; ?></a>
<a href="product-left-sidebar.php?id=<?php echo $order['items'][0]['product']['product_id']; ?>" class="cart_pro_title">
<?php echo $order['items'][0]['product']['name']; ?>
</a>
<span class="cart-price">Unit Price: <span><?php echo $order['items'][0]['price']; ?></span></span>
<div class="cart-price">
<span class="subtotal-<?php echo $order['_id']; ?>">Subtotal: <?php echo $order['total_amount'] ?></span>
</div>
<!-- 02-16-2024 Stacy added style -->
<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('<?php echo $order['_id']; ?>' , '<?php echo $order['items'][0]['_id']; ?>')">-</div>
<input style="width:100px; height:40px" id="qty-input-<?php echo $order['items'][0]['_id']; ?>" class="qty-input" type="number" name="ec_qtybtn" value="<?php echo $order['items'][0]['quantity']; ?>" oninput="handleQtyInput(this, '<?php echo $order['_id']; ?>', '<?php echo $order['items'][0]['_id']; ?>')" />
<div class="qty-btn" style="color:#ffaa00; font-size:30px; padding-left:5px; cursor: pointer;" onclick="qtyIncrement('<?php echo $order['_id']; ?>' , '<?php echo $order['items'][0]['_id']; ?>', false)">+</div>
<div class="qty-plus-minuses" style="display:flex; overflow:visible; align-items:center; margin-top:5px;">
<div class="qty-btn" style="color:#ffaa00; font-size:35px; margin-right:5px; cursor: pointer;" onclick="qtyDecrement('<?php echo $order['_id']; ?>' ,
'<?php echo $order['items'][0]['_id']; ?>')" onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">-
</div>
<input style="width:100px; height:40px" id="qty-input-<?php echo $order['items'][0]['_id']; ?>" class="qty-input" type="number"
name="ec_qtybtn" value="<?php echo $order['items'][0]['quantity']; ?>" oninput="handleQtyInput(this, '<?php echo $order['_id']; ?>',
'<?php echo $order['items'][0]['_id']; ?>')" />
<div class="qty-btn" style="color:#ffaa00; font-size:30px; margin-left:5px; cursor: pointer;" onclick="qtyIncrement('<?php echo $order['_id']; ?>' ,
'<?php echo $order['items'][0]['_id']; ?>', false)" onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">+
</div>
<!-- <a class="remove">x</a> -->
<!-- <a href="#" class="removeCart" onclick="deleteOrder('<?php #echo $order['_id']; ?>')">x</a> -->
<a href="#" class="removeCart" onclick="deleteOrder('<?php echo $order['_id']; ?>')"><i class="ecicon eci-trash" style="padding:20px; opacity:70%"></i></a>
<a href="#" class="removeCart" style="margin-left:30px;" onclick="deleteOrder('<?php echo $order['_id']; ?>')">
<i class="ecicon eci-trash" style="color:#7e7e7e;" onmouseover="this.style.color='#aaaaaa'"
onmouseout="this.style.color='#7e7e7e'"></i>
</a>
</div>
<!-- 02-16-2024 Stacy added style -->
</div>

View File

@ -487,27 +487,34 @@ if (isset($_GET['id'])) {
<div class="ec-single-cart" style="display:flex; flex-direction:row; width:80%; overflow:visible; text-align:center; align-items:center; ">
<!-- 02-13-24 Jun Jihad Contact Seller will appear to Variable products with no price -->
<?php
$product_price = (!empty($product_details['sale_price'])) ? $product_details['sale_price'] : $product_details['regular_price'] ;
if ($_SESSION["isLoggedIn"]) {
if ($product_details['product_type'] === "variable") {
echo '<div class="qty-btn" style="color:#ffaa00; font-size:35px; padding-right:5px; cursor: pointer;" onclick="decrement()">-</div>';
echo '<div class="qty-btn" style="color:#ffaa00; font-size:35px; padding-right:5px; cursor: pointer;" onclick="decrement()"
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">-</div>';
echo '<input class="qty-inputs" style="width:110px; height:40px" type="number" name="ec_qtybtn" value="';
echo (!empty($product_details['minimum_order'])) ? $product_details['minimum_order'] : "1";
echo '" id="qty-input" />';
echo '<div class="qty-btn" style="color:#ffaa00; font-size:25px; padding-left:5px; cursor: pointer;" onclick="increment()">+</div>';
echo '<div style="display:flex; margin-left:45px;"><button type="button" class="btn btn-primary" id="contactSellerButton" style="background:#ffaa00; width:190px;" data-bs-toggle="modal" data-bs-target="#priceModal"><i class="fi-rr-envelope" style="font-size:20px; margin-bottom:-3px; margin-right:10px;"></i>Contact Seller</button>';
echo '<div class="qty-btn" style="color:#ffaa00; font-size:25px; padding-left:5px; cursor: pointer;" onclick="increment()"
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">+</div>';
echo '<div style="display:flex; margin-left:45px;"><button type="button" class="btn btn-primary" id="contactSellerButton" style="background:#ffaa00; width:190px;"
data-bs-toggle="modal" data-bs-target="#priceModal"><i class="fi-rr-envelope" style="font-size:20px; margin-bottom:-3px; margin-right:10px;"></i>Contact Seller</button>';
echo '<button class="btn btn-primary" id="addToCartButton" style="display:none">Add To Cart</button>';
echo '<div class="ec-single-wishlist">
<a class="ec-btn-group wishlist" title="Wishlist" onclick="wishlist()"><i class="fi fi-rr-heart" style="color:#B80F0A; font-size:20px;"></i></a>
</div></div>';
} else {
if (!empty($product_details['regular_price']) || !empty($product_details['sale_price'])) {
echo '<div class="qty-btn" style="color:#ffaa00; font-size:35px; padding-right:5px; cursor: pointer;" onclick="decrement()">-</div>';
echo '<div class="qty-btn" style="color:#ffaa00; font-size:35px; margin-right:5px; cursor: pointer;" onclick="decrement()"
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">-</div>';
echo '<input class="qty-inputs" style="width:100px; height:40px" type="number" name="ec_qtybtn" value="';
echo (!empty($product_details['minimum_order'])) ? $product_details['minimum_order'] : "1";
echo '" id="qty-input" />';
echo '<div class="qty-btn" style="color:#ffaa00; font-size:25px; padding-left:5px; cursor: pointer;" onclick="increment()">+</div>';
// echo '<div id="addToCartMessage" style="border:1px solid red;"></div>';
echo '<div> <div id="addToCartMessage" style="padding-left:45px;"></div> <button class="btn btn-primary" id="addToCartButton" style="text-wrap:nowrap; background:#ffaa00; margin-left:55px;"><i class="fi-rr-shopping-bag" style="font-size:20px; margin-bottom:-3px; margin-right:10px;"></i>Add To Cart</button></div>';
echo '<div class="qty-btn" style="color:#ffaa00; font-size:25px; margin-left:5px; cursor: pointer;" onclick="increment()"
onmouseover="this.style.color=\'#a15d00\'" onmouseout="this.style.color=\'#ffaa00\'">+</div>';
echo '<div> <div id="addToCartMessage" style="padding-left:45px;"></div> <button class="btn btn-primary" id="addToCartButton" style="text-wrap:nowrap;
background:#ffaa00; margin-left:55px;" onmouseover="this.style.background=\'#df9000\'" onmouseout="this.style.background=\'#ffaa00\'">
<i class="fi-rr-shopping-bag" style="font-size:20px; margin-bottom:-3px; margin-right:10px;"></i>Add To Cart</button></div>';
echo '<div class="ec-single-wishlist">
<a class="ec-btn-group wishlist" title="Wishlist" onclick="wishlist()"><i class="fi fi-rr-heart" style="color:#B80F0A; font-size:20px;"></i></a>
</div>';
@ -517,7 +524,8 @@ if (isset($_GET['id'])) {
}
} else {
echo '<div class="login-button" style=""><p style="color:red; text-wrap:nowrap;">Please log in to your account.</p>';
echo '<a href="login.php" style="margin-left:-2px;"><button type="button" class="btn btn-primary" style="margin-left:-2px; margin-top:-20px; background:#ffaa00; border-radius:10px; letter-spacing:1px;" data-bs-toggle="modal">LOGIN</button></a></div>';
echo '<a href="login.php" style="margin-left:-2px;"><button type="button" class="btn btn-primary" style="margin-left:-2px; margin-top:-20px; background:#ffaa00;
border-radius:10px; letter-spacing:1px;" data-bs-toggle="modal">LOGIN</button></a></div>';
}
?>
<!-- <div class="ec-single-wishlist" style="border: 1px solid yellow;">
@ -626,12 +634,120 @@ if (isset($_GET['id'])) {
</div> -->
</div>
<script>
function increment() {
/* 04-18-24 raymart added functioning the quantity to handle if the product has price matrix */
function handleInput(action) {
var qtyInput = document.getElementById('qty-input');
qtyInput.value = parseInt(qtyInput.value) + 1;
var currentQuantity = parseInt(qtyInput.value);
var minimumOrder = <?php echo (!empty($product_details['minimum_order'])) ? $product_details['minimum_order'] : "1"; ?>;
/* default to quantity 1 if input is empty */
if (!currentQuantity || isNaN(currentQuantity)) {
currentQuantity = 1;
}
/* default to minimum quantity if the product has minimun order */
if (currentQuantity < minimumOrder) {
currentQuantity = minimumOrder;
console.log("The minimum order quantity is " + minimumOrder);
}
/* Ensure the quantity never goes below 1 */
if (action === 'increment') {
currentQuantity += 1;
} else if (action === 'decrement' && currentQuantity > 1) {
currentQuantity -= 1;
}
currentQuantity = Math.max(currentQuantity, 1);
qtyInput.value = currentQuantity;
var handlePrice = document.getElementById('productNewPrice') || document.getElementById('productPrice');
var product_price = '<?php echo $product_price; ?>';
var priceMatrices = <?php echo (!empty($product_details['price_matrix'])) ? json_encode($product_details['price_matrix']) : "[]"; ?>;
var foundPrice = false;
for (var m = 0; m < priceMatrices.length; m++) {
var priceMatrix = priceMatrices[m];
for (var i = 0; i < priceMatrix.length; i++) {
var matrixQuantity = parseFloat(priceMatrix[i].quantity);
var nextMatrixQuantity = (i < priceMatrix.length - 1) ? parseFloat(priceMatrix[i + 1].quantity) : Infinity;
if (currentQuantity >= matrixQuantity && currentQuantity < nextMatrixQuantity) {
var unitPrice = parseFloat(priceMatrix[i].price);
handlePrice.innerText = unitPrice.toFixed(2).toString().replace(/\.00$/, '');
foundPrice = true;
break;
}
}
if (foundPrice) {
break;
}
}
if (!foundPrice) {
// Handle when quantity exceeds the highest price matrix
var lastMatrix = priceMatrices[priceMatrices.length - 1];
var highestQuantity = parseFloat(lastMatrix[lastMatrix.length - 1].quantity);
if (currentQuantity >= highestQuantity) {
var highestPrice = parseFloat(lastMatrix[lastMatrix.length - 1].price);
handlePrice.innerText = highestPrice.toFixed(2).replace(/\.00$/, '');
foundPrice = true;
}
}
// If original price is within the quantity range
if (!foundPrice) {
handlePrice.innerText = product_price;
}
}
function decrement() {
function increment() {
var qtyInput = document.getElementById('qty-input');
var currentQuantity = parseInt(qtyInput.value);
currentQuantity++;
qtyInput.value = currentQuantity;
var incrementPrice;
if (document.getElementById('productNewPrice')) {
incrementPrice = document.getElementById('productNewPrice');
} else {
incrementPrice = document.getElementById('productPrice');
}
// var productPrice = document.getElementById('productPrice');
var product_price = '<?php echo $product_price; ?>';
var foundPrice = false;
var priceMatrix = <?php echo (!empty($product_details['price_matrix'])) ? json_encode($product_details['price_matrix']) : "[]"; ?>;
/* to determine if regular price or price matrix but it depends to the quantity */
if (priceMatrix.length > 0) {
for (var i = 0; i < priceMatrix.length; i++) {
for (var j = 0; j < priceMatrix[i].length; j++) {
var matrixQuantity = parseFloat(priceMatrix[i][j].quantity);
var nextMatrixQuantity = (j < priceMatrix[i].length - 1) ? parseFloat(priceMatrix[i][j + 1].quantity) : Infinity;
if (currentQuantity >= matrixQuantity && currentQuantity < nextMatrixQuantity) {
var regularPrice = parseFloat(priceMatrix[i][j].price);
var nextPrice = (j < priceMatrix[i].length - 1) ? parseFloat(priceMatrix[i][j + 1].price) : product_price;
var unitPrice = regularPrice;
incrementPrice.innerText = parseFloat(unitPrice.toFixed(2)).toString(); // Convert to floating-point number and then to string
foundPrice = true;
break;
}
}
if (foundPrice) {
break;
}
}
}
}
/* function increment() {
var qtyInput = document.getElementById('qty-input');
qtyInput.value = parseInt(qtyInput.value) + 1;
} */
/* function decrement() {
var qtyInput = document.getElementById('qty-input');
var currentQuantity = parseInt(qtyInput.value);
@ -646,7 +762,64 @@ if (isset($_GET['id'])) {
qtyInput.value = currentQuantity - 1;
}
<?php endif; ?>
} */
function decrement() {
var qtyInput = document.getElementById('qty-input');
var currentQuantity = parseInt(qtyInput.value);
var minimumOrder = <?php echo (!empty($product_details['minimum_order'])) ? $product_details['minimum_order'] : "1"; ?>;
if (currentQuantity <= minimumOrder) {
console.log("The minimum order quantity is " + minimumOrder);
return;
}
if (currentQuantity > 1) {
currentQuantity--;
} else {
return; // Don't decrement further if quantity is already 1
}
qtyInput.value = currentQuantity;
var decrementPrice;
if (document.getElementById('productNewPrice')) {
decrementPrice = document.getElementById('productNewPrice');
} else {
decrementPrice = document.getElementById('productPrice');
}
// var productPrice = document.getElementById('productPrice');
var product_price = '<?php echo $product_price; ?>';
var foundPrice = false;
var priceMatrix = <?php echo (!empty($product_details['price_matrix'])) ? json_encode($product_details['price_matrix']) : "[]"; ?>;
/* to determine if regular price or price matrix but it depends to the quantity */
if (priceMatrix.length > 0) {
for (var i = 0; i < priceMatrix.length; i++) {
for (var j = 0; j < priceMatrix[i].length; j++) {
var matrixQuantity = parseFloat(priceMatrix[i][j].quantity);
var nextMatrixQuantity = (j < priceMatrix[i].length - 1) ? parseFloat(priceMatrix[i][j + 1].quantity) : Infinity;
if (currentQuantity >= matrixQuantity && currentQuantity < nextMatrixQuantity) {
var regularPrice = parseFloat(priceMatrix[i][j].price);
var nextPrice = (j < priceMatrix[i].length - 1) ? parseFloat(priceMatrix[i][j + 1].price) : product_price;
var unitPrice = regularPrice;
decrementPrice.innerText = parseFloat(unitPrice.toFixed(2)).toString(); /* Convert to floating-point number and then to string */
foundPrice = true;
break;
} else if (currentQuantity < matrixQuantity) {
/* If current quantity is less than the minimum in the price matrix, display the regular price */
decrementPrice.innerText = parseFloat(product_price).toFixed(2).replace(/\.00$/, ''); /* Remove trailing .00 */
foundPrice = true;
break;
}
}
if (foundPrice) {
break;
}
}
}
}
/* 04-18-24 raymart added functioning the quantity to handle if the product has price matrix */
<?php
@ -772,7 +945,22 @@ if (isset($_GET['id'])) {
if (parseInt(quantityValue) < minimumOrder) {
quantityValue = minimumOrder;
alert("The minimum order quantity is " + minimumOrder);
}
} /* else {
if (priceMatrix.length > 0) {
var selectedPrice = null;
for (var i = 0; i < priceMatrix.length; i++) {
if (parseInt(priceMatrix[i].quantity) === parseInt(quantityValue)) {
selectedPrice = priceMatrix[i].price;
break;
}
}
if (selectedPrice !== null) {
document.getElementById("price-display").innerText = "Price: $" + selectedPrice;
} else {
document.getElementById("price-display").innerText = "Price not available for this quantity";
}
}
} */
// April 3, 2024 Jun Jihad Apply Matrix
var productPrice;
@ -906,25 +1094,29 @@ if (isset($_GET['id'])) {
newOrder.id = `order_${response._id}`;
console.log(response)
newOrder.innerHTML = `
<a href="shop-left-sidebar-col-4.php" class="sidekka_pro_img">
<img src="${response.items[0].product.product_image}" alt="product">
</a>
<div class="ec-pro-content">
<a href="shop-left-sidebar-col-4.php" class="cart_pro_title">${response.items[0].product.name}</a>
<span class="cart-price" id="cart-price">
Unit Price: <span>${response.items[0].price}</span>
</span>
<span id="subtotal-${response._id}" class="subtotal-${response._id}">Subtotal: ${totalAmount}</span>
<!-- 02-16-2024 Stacy added style -->
<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)"/>
<div class="qty-btn" style="color:#ffaa00; font-size:30px; padding-left:5px; cursor: pointer;" onclick="qtyIncrement('${response._id}', '${response.items[0]._id}', true)">+</div>
<a href="#" class="removeCart" onclick="deleteOrder('${response._id}')"><i class="ecicon eci-trash" style="padding:20px; opacity:70%"></i></a>
</div>
<!-- 02-16-2024 Stacy added style -->
</div>
`;
<a href="shop-left-sidebar-col-4.php" class="sidekka_pro_img">
<img src="${response.items[0].product.product_image}" alt="product">
</a>
<div class="ec-pro-content">
<a href="shop-left-sidebar-col-4.php" class="cart_pro_title">${response.items[0].product.name}</a>
<span class="cart-price" id="cart-price">
Unit Price: <span>${response.items[0].price}</span>
</span>
<span id="subtotal-${response._id}" class="subtotal-${response._id}">Subtotal: ${totalAmount}</span>
<!-- 02-16-2024 Stacy added style -->
<div class="qty-plus-minuses" style="display:flex; overflow:visible; align-items:center; margin-top:5px;">
<div class="qty-btn" style="color:#ffaa00; font-size:35px; margin-right:5px; cursor: pointer;" onclick="qtyDecrement('${response._id}', '${response.items[0]._id}', true)"
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">-</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)"/>
<div class="qty-btn" style="color:#ffaa00; font-size:30px; margin-left:5px; cursor: pointer;" onclick="qtyIncrement('${response._id}', '${response.items[0]._id}', true)"
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">+</div>
<a href="#" class="removeCart" style="margin-left:30px;" onclick="deleteOrder('${response._id}')">
<i class="ecicon eci-trash" style="color:#7e7e7e;" onmouseover="this.style.color='#aaaaaa'"
onmouseout="this.style.color='#7e7e7e'"></i></a>
</div>
<!-- 02-16-2024 Stacy added style -->
</div>
`;
getLatestOrders()
updateCartItemCount()
cartList.appendChild(newOrder);
@ -985,23 +1177,29 @@ if (isset($_GET['id'])) {
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>
<div class="ec-pro-content">
<a href="shop-left-sidebar-col-4.php" class="cart_pro_title">${response.items[0].product.name}</a>
<span class="cart-price" id="cart-price">
Unit Price: <span>${response.items[0].price}</span>
</span>
<span id="subtotal-${response._id}" class="subtotal-${response._id}">Subtotal: ${totalAmount}</span>
<div class="qty-plus-minuses">
<div class="qty-btn" onclick="qtyDecrement('${response._id}', '${response.items[0]._id}', true)">-</div>
<input 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)"/>
<div class="qty-btn" onclick="qtyIncrement('${response._id}', '${response.items[0]._id}', true)">+</div>
</div>
<a href="#" class="removeCart" onclick="deleteOrder('${response._id}')">x</a>
</div>
`;
<a href="shop-left-sidebar-col-4.php" class="sidekka_pro_img">
<img src="${response.items[0].product.product_image}" alt="product">
</a>
<div class="ec-pro-content">
<a href="shop-left-sidebar-col-4.php" class="cart_pro_title">${response.items[0].product.name}</a>
<span class="cart-price" id="cart-price">
Unit Price: <span>${response.items[0].price}</span>
</span>
<span id="subtotal-${response._id}" class="subtotal-${response._id}">Subtotal: ${totalAmount}</span>
<!-- 04-17-2024 Stacy added style -->
<div class="qty-plus-minuses" style="display:flex; overflow:visible; align-items:center; margin-top:5px;">
<div class="qty-btn" style="color:#ffaa00; font-size:35px; margin-right:5px; cursor: pointer;" onclick="qtyDecrement('${response._id}', '${response.items[0]._id}', true)"
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">-</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)"/>
<div class="qty-btn" style="color:#ffaa00; font-size:30px; margin-left:5px; cursor: pointer;" onclick="qtyIncrement('${response._id}', '${response.items[0]._id}', true)"
onmouseover="this.style.color='#a15d00'" onmouseout="this.style.color='#ffaa00'">+</div>
<a href="#" class="removeCart" style="margin-left:30px;" onclick="deleteOrder('${response._id}')">
<i class="ecicon eci-trash" style="color:#7e7e7e;" onmouseover="this.style.color='#aaaaaa'"
onmouseout="this.style.color='#7e7e7e'"></i></a>
</div>
<!-- 04-17-2024 Stacy added style -->
</div>
`;
document.getElementById(`qty-input-${response.items[0]._id}`).value = updatedQuantity;
} else {
// If the cart item doesn't exist, create a new one

View File

@ -353,9 +353,7 @@ if ($_SESSION["isVendor"] == true) {
$_SESSION['cart_items'] = $order_data;
foreach ($order_data as $order) {
// Ensure that the required data is available before accessing it
if (isset($order['status']) && (strtoupper($order['status']) === 'TO PAY') || (strtoupper($order['status']) === 'TO SHIP')
|| (strtoupper($order['status']) === 'TO RECEIVE') || (strtoupper($order['status']) === 'COMPLETED')
&& isset($order['items'][0]['product'])) {
if (isset($order['status']) && (strtoupper($order['status']) === 'TO PAY' || strtoupper($order['status']) === 'TO SHIP' || strtoupper($order['status']) === 'TO RECEIVE' || strtoupper($order['status']) === 'COMPLETED') && isset($order['items'][0]['product'])) {
$orderExist = true;
$totalAmount += $order['total_amount'];
?>
@ -376,9 +374,9 @@ if ($_SESSION["isVendor"] == true) {
<?php
}
}
if (empty($order['status'])) {
echo '<tr><p style="padding-top:30px; padding-left:20px;">No Purchased Order/s Yet.</p></tr>';
}
// if (empty($order['status'])) {
// echo '<tr><p style="padding-top:30px; padding-left:20px;">No Purchased Order/s Yet.</p></tr>';
// }
}
}
// } else if (empty($order['status'])) {

View File

@ -250,7 +250,7 @@ if ($_SESSION["isVendor"] == 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;">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#secondModal">Add New Address</button>
<button type="button" class="btn btn-primary mb-3" 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">
@ -362,7 +362,7 @@ if ($_SESSION["isVendor"] == true) {
<label for="addressCountry" class="text-dark font-weight-medium pt-3 mb-2">Country</label>
<input type="text" class="form-control" id="addressCountry" >
</div>
<button type="button" class="btn btn-primary" id="submitBtn">Submit</button>
<button type="button" class="btn btn-primary mt-4" id="submitBtn">Submit</button>
</form>
@ -447,7 +447,7 @@ if ($_SESSION["isVendor"] == true) {
<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>
<button type="button" class="btn btn-primary mt-4" id="submitBtn2">Submit</button>
</form>
</div>

View File

@ -202,7 +202,7 @@ $products = productList();
</thead>
<tbody>
<?php
$products = productListVendor($vendorId);
$products = allProductListVendor($vendorId);
$totalProducts = count($products);
// 03-11-2024 Stacy added for products pagination
$productsPerPage = 10;

View File

@ -276,11 +276,28 @@ $products = productList();
<!-- 03-11-2024 Stacy added pagination for vendor -->
<!-- Ec Pagination Start -->
<div class="pagination mt-3">
<?php
for ($i = 1; $i <= $totalPages; $i++) {
echo "<a href='?page=$i' class='" . ($currentpage == $i ? 'active' : '') . "'>$i</a>";
<?php
$start = max(1, $currentpage - 2);
$end = min($totalPages, $start + 4);
if ($start > 1) {
echo "<a href='?page=1'>1</a>";
if ($start > 2) {
echo "<span>&nbsp;...&nbsp;</span>";
}
}
?>
for ($i = $start; $i <= $end; $i++) {
echo "<a href='?page=$i' class='" . ($currentpage == $i ? 'active' : '') . "'>$i</a>&nbsp;";
}
if ($end < $totalPages) {
if ($end < $totalPages - 1) {
echo "<span>&nbsp;...&nbsp;</span>";
}
echo "<a href='?page=$totalPages'>$totalPages</a>";
}
?>
</div>
<!-- Ec Pagination End -->
</div>

View File

@ -485,6 +485,7 @@ if ($_SESSION["isCustomer"] == true) {
},
success: function(response) {
// Handle successful response
console.log(response);
var paymentId = response.payment.reference_number;
$('#paymentIdSpan').text(paymentId);
var gross_price = response.payment.details[0]?.attributes.data.attributes.amount;

View File

@ -304,7 +304,7 @@ if ($_SESSION["isCustomer"] == 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;">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#secondModal">Add New Address</button>
<button type="button" class="btn btn-primary mb-3" 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">
@ -420,7 +420,7 @@ if ($_SESSION["isCustomer"] == true) {
<label for="addressCountry" class="text-dark font-weight-medium pt-3 mb-2">Country</label>
<input type="text" class="form-control" id="addressCountry">
</div>
<button type="button" class="btn btn-primary" id="submitBtn">Submit</button>
<button type="button" class="btn btn-primary mt-4" id="submitBtn">Submit</button>
</form>
@ -505,7 +505,7 @@ if ($_SESSION["isCustomer"] == true) {
<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>
<button type="button" class="btn btn-primary mt-4" id="submitBtn2">Submit</button>
</form>
</div>
@ -519,7 +519,7 @@ if ($_SESSION["isCustomer"] == 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;">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#secondBankModal">Add New Bank</button>
<button type="button" class="btn btn-primary mb-3" data-bs-toggle="modal" data-bs-target="#secondBankModal">Add New Bank</button>
<!-- Display a list of banks and let the user choose -->
<form id="BankForm">
@ -571,7 +571,7 @@ if ($_SESSION["isCustomer"] == true) {
<input type="text" class="form-control" id="bankAccountName">
</div>
<button type="button" class="btn btn-primary" id="submitBankBtn">Add Bank</button>
<button type="button" class="btn btn-primary mt-4" id="submitBankBtn">Add Bank</button>
</form>