cart & wishlist countdown in mobile view

This commit is contained in:
Stacy 2024-05-03 18:12:24 +08:00
parent 02b2f799db
commit 7d44fae6bd
4 changed files with 39 additions and 25 deletions

View File

@ -134,33 +134,35 @@ if (!empty($_GET['minPrice']) || !empty($_GET['maxPrice']) || !empty($_GET['cate
<link rel="stylesheet" id="bg-switcher-css" href="assets/css/backgrounds/bg-4.css">
<script>
function updateCartItemCount() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "cartitems.php?id=<?php echo $_SESSION['customerId']; ?>", true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var data = xhr.responseText;
if (data !== "") {
console.log("Data: " + data);
document.getElementById("cartItemCount").innerHTML = data;
var xhr = new XMLHttpRequest();
xhr.open("GET", "cartitems.php?id=<?php echo $_SESSION['customerId']; ?>", true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var data = xhr.responseText;
if (data !== "") {
console.log("Data: " + data);
document.getElementById("cartItemCount").innerHTML = data;
document.getElementById("cartNewItemCount").innerHTML = data;
}
}
};
xhr.send();
}
}
};
xhr.send();
}
function updateWishItemCount() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "wishlistitems.php?id=<?php echo $_SESSION['customerId']; ?>", true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var data = xhr.responseText;
if (data !== "") {
document.getElementById("wishItemCount").innerHTML = data;
function updateWishItemCount() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "wishlistitems.php?id=<?php echo $_SESSION['customerId']; ?>", true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var data = xhr.responseText;
if (data !== "") {
document.getElementById("wishItemCount").innerHTML = data;
document.getElementById("wishNewItemCount").innerHTML = data;
}
}
};
xhr.send();
}
}
};
xhr.send();
}
</script>
<!-- raymart added css feb 14 2024 -->

View File

@ -76,11 +76,13 @@ if ($_SESSION["userId"] <> "") {
}
</style>
<script>
function updateCartItemCount() {
function updateCartItemCount() {
$.get("cartitems.php?id=<?php echo $_SESSION['customerId']; ?>", function(data, status) {
if (data != "") {
console.log("Data: " + data + "\nStatus: " + status);
document.getElementById("cartItemCount").innerHTML = data;
document.getElementById("cartNewItemCount").innerHTML = data;
}
});
}
@ -89,6 +91,8 @@ if ($_SESSION["userId"] <> "") {
$.get("wishlistitems.php?id=<?php echo $_SESSION['customerId']; ?>", function(data) {
if (data != "") {
document.getElementById("wishItemCount").innerHTML = data;
document.getElementById("wishNewItemCount").innerHTML = data;
}
});
}

View File

@ -150,6 +150,7 @@ $filteredProducts = [];
if (data !== "") {
console.log("Data: " + data);
document.getElementById("cartItemCount").innerHTML = data;
document.getElementById("cartNewItemCount").innerHTML = data;
}
}
};
@ -164,6 +165,7 @@ function updateWishItemCount() {
var data = xhr.responseText;
if (data !== "") {
document.getElementById("wishItemCount").innerHTML = data;
document.getElementById("wishNewItemCount").innerHTML = data;
}
}
};

View File

@ -50,12 +50,15 @@ if ($_SESSION["userId"] <> "") {
<!-- Background css -->
<link rel="stylesheet" id="bg-switcher-css" href="assets/css/backgrounds/bg-4.css">
<script>
function updateCartItemCount() {
$.get("cartitems.php?id=<?php echo $_SESSION['customerId']; ?>", function(data, status) {
if (data != "") {
console.log("Data: " + data + "\nStatus: " + status);
document.getElementById("cartItemCount").innerHTML = data;
document.getElementById("cartNewItemCount").innerHTML = data;
}
});
}
@ -64,10 +67,13 @@ if ($_SESSION["userId"] <> "") {
$.get("wishlistitems.php?id=<?php echo $_SESSION['customerId']; ?>", function(data) {
if (data != "") {
document.getElementById("wishItemCount").innerHTML = data;
document.getElementById("wishNewItemCount").innerHTML = data;
}
});
}
</script>
<!-- raymart added css feb 14 2024 -->
<style>
.ec-product-inner .ec-pro-image .ec-pro-actions .add-to-cart {