Compare commits
2 Commits
ac3de653e4
...
61d9aaf104
Author | SHA1 | Date |
---|---|---|
erwin | 61d9aaf104 | |
Jun Barroga | 959f2e6258 |
|
@ -1363,7 +1363,7 @@ function addVendor(
|
|||
$country,
|
||||
$email,
|
||||
$phone,
|
||||
$dateRegistered,
|
||||
$dateRegistered
|
||||
) {
|
||||
$curl = curl_init();
|
||||
|
||||
|
|
|
@ -334,54 +334,17 @@ if (isset($_GET['id'])) {
|
|||
<div class="ec-single-price">
|
||||
<span class="ec-single-ps-title">As low as</span>
|
||||
<?php
|
||||
if ($product_details['product_type'] === "simple") {
|
||||
if (isset($product_details['sale_price']) && $product_details['sale_price'] > 0) {
|
||||
echo '<span id="productPrice" class="old-price">' . $product_details['regular_price'] . '</span>';
|
||||
echo '<span id="productNewPrice" class="new-price">' . $product_details['sale_price'] . '</span>';
|
||||
} else {
|
||||
echo '<span id="productPrice" class="new-price">' . $product_details['regular_price'] . '</span>';
|
||||
}
|
||||
} elseif ($product_details['product_type'] === "variable") {
|
||||
$lowest_regular_price = null;
|
||||
$highest_regular_price = null;
|
||||
$lowest_sale_price = null;
|
||||
$highest_sale_price = null;
|
||||
|
||||
if (isset($variation_details) && is_array($variation_details)) {
|
||||
foreach ($variation_details as $index => $variation) {
|
||||
$regular_price = isset($variation['regular_price']) ? $variation['regular_price'] : 0;
|
||||
$sale_price = isset($variation['sale_price']) ? $variation['sale_price'] : 0;
|
||||
|
||||
// Update the minimum and maximum prices only if they are not null
|
||||
if ($lowest_regular_price === null || $regular_price < $lowest_regular_price) {
|
||||
$lowest_regular_price = $regular_price;
|
||||
}
|
||||
|
||||
if ($highest_regular_price === null || $regular_price > $highest_regular_price) {
|
||||
$highest_regular_price = $regular_price;
|
||||
}
|
||||
|
||||
if ($lowest_sale_price === null || $sale_price < $lowest_sale_price) {
|
||||
$lowest_sale_price = $sale_price;
|
||||
}
|
||||
|
||||
if ($highest_sale_price === null || $sale_price > $highest_sale_price) {
|
||||
$highest_sale_price = $sale_price;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Display the range of prices based on the presence of sale prices
|
||||
if ($lowest_sale_price !== null && $highest_sale_price !== null && $lowest_sale_price > 0 && $highest_sale_price > 0) {
|
||||
echo '<span id="productPrice" class="new-price">' . '₱' . $lowest_sale_price . ' - ₱' . $highest_sale_price . '</span>';
|
||||
} elseif ($lowest_regular_price !== null && $highest_regular_price !== null) {
|
||||
echo '<span id="productPrice" class="new-price">' . '₱' . $lowest_regular_price . ' - ₱' . $highest_regular_price . '</span>';
|
||||
}
|
||||
}
|
||||
// 02-13-24 Jun Jihad Removed Logic to DIsplay Price Range of Variable Products
|
||||
if (isset($product_details['sale_price']) && $product_details['sale_price'] > 0) {
|
||||
echo '<span id="productPrice" class="old-price">' . $product_details['regular_price'] . '</span>';
|
||||
echo '<span id="productNewPrice" class="new-price">' . $product_details['sale_price'] . '</span>';
|
||||
} elseif (!isset($product_details['regular_price']) || $product_details['regular_price'] <= 0) {
|
||||
echo '<span id="productPrice" class="new-price">Contact Seller for Price</span>';
|
||||
} else {
|
||||
echo '<span id="productPrice" class="new-price">' . $product_details['regular_price'] . '</span>';
|
||||
}
|
||||
// 02-13-24 Jun Jihad Removed Logic to DIsplay Price Range of Variable Products
|
||||
?>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="ec-single-stoke">
|
||||
<span class="ec-single-ps-title">Stocks Available</span>
|
||||
|
@ -389,68 +352,83 @@ if (isset($_GET['id'])) {
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 20240212 Jun Jihad Include Parent Product in the Variation Selection -->
|
||||
<?php
|
||||
if (isset($variation_details) && is_array($variation_details)) {
|
||||
if (isset($variation_details) && is_array($variation_details)) {
|
||||
?>
|
||||
<div class="ec-pro-variation">
|
||||
<div class="ec-pro-variation-inner ec-pro-variation-size">
|
||||
<span>VARIATION</span>
|
||||
<div class="ec-pro-variation-content">
|
||||
<ul class="eccart-pro-items">
|
||||
<?php
|
||||
$main_product_image = isset($product_details["product_image"]) ? $product_details["product_image"] : 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
?>
|
||||
<div class="ec-pro-variation">
|
||||
<div class="ec-pro-variation-inner ec-pro-variation-size">
|
||||
<span>VARIATION</span>
|
||||
<div class="ec-pro-variation-content">
|
||||
<ul class="eccart-pro-items">
|
||||
<?php
|
||||
foreach ($variation_details as $index => $variation) {
|
||||
$variationImage = isset($variation["product_image"]) ? $variation["product_image"] : 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
?>
|
||||
<a href="javascript:void(0);" onclick="selectVariation(<?php echo htmlspecialchars(json_encode($variation), ENT_QUOTES, 'UTF-8'); ?>)">
|
||||
<li style="width: 100px; height: 100px">
|
||||
<img src="<?php echo $variationImage; ?>" alt="product">
|
||||
</li>
|
||||
</a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function selectVariation(variation) {
|
||||
console.log("Variation selected: ", variation);
|
||||
|
||||
document.getElementById("productDescription").innerHTML = variation.specifications;
|
||||
document.getElementById("shortDescription").innerHTML = variation.product_description;
|
||||
document.getElementById("productTitle").innerText = variation.product_name;
|
||||
document.getElementById("product_Id").value = variation._id;
|
||||
var productImage = variation.product_image || 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
|
||||
document.getElementById('mainProductImage').src = productImage;
|
||||
|
||||
document.getElementById("productTitlemodal").innerText = variation.product_name;
|
||||
document.getElementById('mainProductImagemodal').src = productImage;
|
||||
|
||||
if (variation.regular_price || variation.sale_price) {
|
||||
// Variation has a price, show "Add to Cart" button
|
||||
document.getElementById("productPrice").innerText = variation.sale_price ? variation.sale_price : variation.regular_price;
|
||||
document.getElementById("productStock").innerText = variation.stock;
|
||||
document.getElementById('addToCartButton').disabled = false;
|
||||
document.getElementById("addToCartButton").style.display = "block";
|
||||
document.getElementById("contactSellerButton").style.display = "none";
|
||||
} else {
|
||||
// Variation doesn't have a price, show "Contact seller" button
|
||||
document.getElementById("productPrice").innerText = "Contact seller for price";
|
||||
document.getElementById("productStock").innerText = "Available";
|
||||
document.getElementById('addToCartButton').disabled = true;
|
||||
document.getElementById("addToCartButton").style.display = "none";
|
||||
document.getElementById("contactSellerButton").style.display = "block";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<a href="javascript:void(0);" onclick="selectVariation(<?php echo htmlspecialchars(json_encode($product_details), ENT_QUOTES, 'UTF-8'); ?>)">
|
||||
<li style="width: 100px; height: 100px">
|
||||
<img src="<?php echo $main_product_image; ?>" alt="product">
|
||||
<?php foreach ($product_details['variables'] as $variable) { ?>
|
||||
<p><?php echo $variable['name'] . ': ' . $variable['value']; ?></p>
|
||||
<?php } ?>
|
||||
</li>
|
||||
</a>
|
||||
|
||||
<?php
|
||||
foreach ($variation_details as $index => $variation) {
|
||||
$variationImage = isset($variation["product_image"]) ? $variation["product_image"] : 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
?>
|
||||
<a href="javascript:void(0);" onclick="selectVariation(<?php echo htmlspecialchars(json_encode($variation), ENT_QUOTES, 'UTF-8'); ?>)">
|
||||
<li style="width: 100px; height: 100px">
|
||||
<img src="<?php echo $variationImage; ?>" alt="product">
|
||||
<?php foreach ($variation['variables'] as $variable) { ?>
|
||||
<p><?php echo $variable['name'] . ': ' . $variable['value']; ?></p>
|
||||
<?php } ?>
|
||||
</li>
|
||||
</a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function selectVariation(variation) {
|
||||
console.log("Variation selected: ", variation);
|
||||
|
||||
document.getElementById("productDescription").innerHTML = variation.specifications;
|
||||
document.getElementById("shortDescription").innerHTML = variation.product_description;
|
||||
document.getElementById("productTitle").innerText = variation.product_name;
|
||||
document.getElementById("product_Id").value = variation._id;
|
||||
var productImage = variation.product_image || 'https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg';
|
||||
|
||||
document.getElementById('mainProductImage').src = productImage;
|
||||
|
||||
document.getElementById("productTitlemodal").innerText = variation.product_name;
|
||||
document.getElementById('mainProductImagemodal').src = productImage;
|
||||
|
||||
if (variation.regular_price || variation.sale_price) {
|
||||
document.getElementById("productPrice").innerText = variation.sale_price ? variation.sale_price : variation.regular_price;
|
||||
document.getElementById("productStock").innerText = variation.stock;
|
||||
document.getElementById('addToCartButton').disabled = false;
|
||||
document.getElementById("addToCartButton").style.display = "block";
|
||||
document.getElementById("contactSellerButton").style.display = "none";
|
||||
} else {
|
||||
document.getElementById("productPrice").innerText = "Contact seller for price";
|
||||
document.getElementById("productStock").innerText = "Available";
|
||||
document.getElementById('addToCartButton').disabled = true;
|
||||
document.getElementById("addToCartButton").style.display = "none";
|
||||
document.getElementById("contactSellerButton").style.display = "block";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<!-- 20240212 Jun Jihad Include Parent Product in the Variation Selection -->
|
||||
|
||||
<div class="ec-single-qty">
|
||||
|
||||
<div class="qty-plus-minuses">
|
||||
|
@ -460,25 +438,43 @@ if (isset($variation_details) && is_array($variation_details)) {
|
|||
</div>
|
||||
|
||||
<div class="ec-single-cart">
|
||||
<?php
|
||||
if ($_SESSION["isLoggedIn"]) {
|
||||
if ($product_details['product_type'] === "variable") {
|
||||
echo '<button class="btn btn-primary" id="addToCartButton" disabled>Add To Cart</button>';
|
||||
echo '<button type="button" class="btn btn-primary" id="contactSellerButton" style="display:none" data-bs-toggle="modal" data-bs-target="#priceModal">Contact seller</button>';
|
||||
} elseif ($product_details['regular_price'] && $product_details['regular_price'] !== "") {
|
||||
// For non-variable products with a regular price, show "Add to Cart" button
|
||||
<!-- 02-13-24 Jun Jihad Contact Seller will appear to Variable products with no price -->
|
||||
<?php
|
||||
if ($_SESSION["isLoggedIn"]) {
|
||||
if ($product_details['product_type'] === "variable") {
|
||||
echo '<button class="btn btn-primary" id="addToCartButton" style="display:none">Add To Cart</button>';
|
||||
echo '<button type="button" class="btn btn-primary" id="contactSellerButton" data-bs-toggle="modal" data-bs-target="#priceModal">Contact seller</button>';
|
||||
} else {
|
||||
if (!empty($product_details['regular_price']) || !empty($product_details['sale_price'])) {
|
||||
echo '<div id="addToCartMessage"></div>';
|
||||
echo '<button class="btn btn-primary" id="addToCartButton">Add To Cart</button>';
|
||||
} else {
|
||||
// For non-variable products without a regular price, show "Contact seller" button
|
||||
echo '<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#priceModal">Contact seller</button>';
|
||||
}
|
||||
} else {
|
||||
// If user is not logged in, prompt to log in
|
||||
echo '<p>Please log in to add to cart.</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
} else {
|
||||
echo '<p>Please log in to add to cart.</p>';
|
||||
}
|
||||
?>
|
||||
<!-- 02-13-24 Jun Jihad Contact Seller will appear to Variable products with no price -->
|
||||
|
||||
|
||||
<!-- <?php
|
||||
// if ($_SESSION["isLoggedIn"]) {
|
||||
// if ($product_details['product_type'] === "variable") {
|
||||
// echo '<button class="btn btn-primary" id="addToCartButton" disabled>Add To Cart</button>';
|
||||
// echo '<button type="button" class="btn btn-primary" id="contactSellerButton" style="display:none" data-bs-toggle="modal" data-bs-target="#priceModal">Contact seller</button>';
|
||||
// } elseif ($product_details['regular_price'] && $product_details['regular_price'] !== "") {
|
||||
// echo '<div id="addToCartMessage"></div>';
|
||||
// echo '<button class="btn btn-primary" id="addToCartButton">Add To Cart</button>';
|
||||
// } else {
|
||||
// echo '<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#priceModal">Contact seller</button>';
|
||||
// }
|
||||
// } else {
|
||||
// echo '<p>Please log in to add to cart.</p>';
|
||||
// }
|
||||
?> -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
// update_selected_variation.php
|
||||
|
||||
// Retrieve the JSON data sent via AJAX
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
// You can process the $data as needed, for example, store it in session
|
||||
session_start();
|
||||
$_SESSION['selected_variation'] = $data;
|
||||
|
||||
var_dump($_SESSION['selected_variation']);
|
||||
// You can also return a response if needed
|
||||
// echo json_encode(['success' => true]);
|
|
@ -1,4 +1,4 @@
|
|||
<div class="ec-vendor-block-items">
|
||||
<!-- <div class="ec-vendor-block-items">
|
||||
<ul>
|
||||
<li <?php if ($_SERVER['REQUEST_URI'] == '/user-profile.php') echo 'class="active"'; ?>><a href="user-profile.php" id="user-profile-link">User Profile</a></li>
|
||||
<li <?php if ($_SERVER['REQUEST_URI'] == '/user-history.php') echo 'class="active"'; ?>><a href="user-history.php" id="purchase-history-link">Purchase History</a></li>
|
||||
|
@ -8,6 +8,28 @@
|
|||
</div>
|
||||
|
||||
|
||||
<style>.ec-vendor-block-items ul li.active a {
|
||||
color: white !important; /* Change the text color */
|
||||
background-color: #3474d4; /* Change the background color */
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
</style> -->
|
||||
|
||||
<?php
|
||||
$current_page = basename($_SERVER['PHP_SELF']);
|
||||
?>
|
||||
|
||||
<div class="ec-vendor-block-items">
|
||||
<ul>
|
||||
<li <?php if ($current_page == 'user-profile.php') echo 'class="active"'; ?>><a href="user-profile.php" id="user-profile-link">User Profile</a></li>
|
||||
<li <?php if ($current_page == 'user-history.php') echo 'class="active"'; ?>><a href="user-history.php" id="purchase-history-link">Purchase History</a></li>
|
||||
<li <?php if ($current_page == 'user-refund-history.php') echo 'class="active"'; ?>><a href="user-refund-history.php" id="refund-history-link">User Refund History</a></li>
|
||||
<li <?php if ($current_page == 'wishlist.php') echo 'class="active"'; ?>><a href="wishlist.php" id="wishlist-link">Wishlist</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<style>.ec-vendor-block-items ul li.active a {
|
||||
color: white !important; /* Change the text color */
|
||||
background-color: #3474d4; /* Change the background color */
|
||||
|
|
Loading…
Reference in New Issue