webupdatev1
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
/>
|
||||
<link rel="stylesheet" href="/assets/css/main.css?v=1735692100" />
|
||||
<link rel="stylesheet" href="/assets/css/navbar.css?v=1767233028" />
|
||||
<link rel="stylesheet" href="/assets/css/cart-wishlist.css" />
|
||||
<link rel="stylesheet" href="/assets/css/shopping.css" />
|
||||
<link rel="stylesheet" href="/assets/css/responsive.css" />
|
||||
<link rel="stylesheet" href="/assets/css/theme-colors.css" />
|
||||
@@ -858,12 +859,12 @@
|
||||
</footer>
|
||||
|
||||
<!-- Core Scripts -->
|
||||
<script src="/assets/js/state-manager.js"></script>
|
||||
<script src="/assets/js/shop-system.js"></script>
|
||||
<script src="/assets/js/cart.js"></script>
|
||||
<script src="/assets/js/api-client.js"></script>
|
||||
<script src="/assets/js/notifications.js"></script>
|
||||
<script src="/assets/js/page-transitions.js?v=1767228800"></script>
|
||||
<script src="/assets/js/back-button-control.js?v=1767228687"></script>
|
||||
<script src="/assets/js/main.js?v=1766708114"></script>
|
||||
<script src="/assets/js/navigation.js?v=1767228687"></script>
|
||||
<script>
|
||||
// Mobile Menu Toggle (Same as other pages)
|
||||
@@ -1172,70 +1173,26 @@
|
||||
applySorting();
|
||||
});
|
||||
|
||||
// Cart Functions - Simple localStorage implementation
|
||||
// Simple Cart and Wishlist Functions
|
||||
function addToCart(productId, name, price, imageurl) {
|
||||
try {
|
||||
const cart = JSON.parse(localStorage.getItem("cart") || "[]");
|
||||
const existingItem = cart.find((item) => item.id === productId);
|
||||
|
||||
if (existingItem) {
|
||||
existingItem.quantity = (existingItem.quantity || 1) + 1;
|
||||
} else {
|
||||
cart.push({ id: productId, name, price, imageurl, quantity: 1 });
|
||||
}
|
||||
|
||||
localStorage.setItem("cart", JSON.stringify(cart));
|
||||
updateCartBadge();
|
||||
showNotification(`${name} added to cart!`, "success");
|
||||
} catch (e) {
|
||||
console.error("Cart error:", e);
|
||||
showNotification("Added to cart!", "success");
|
||||
}
|
||||
window.ShopSystem.addToCart(
|
||||
{
|
||||
id: String(productId),
|
||||
name,
|
||||
price: parseFloat(price),
|
||||
imageurl,
|
||||
},
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
function addToWishlist(productId, name, price, imageurl) {
|
||||
try {
|
||||
const wishlist = JSON.parse(localStorage.getItem("wishlist") || "[]");
|
||||
const exists = wishlist.find((item) => item.id === productId);
|
||||
|
||||
if (!exists) {
|
||||
wishlist.push({ id: productId, name, price, imageurl });
|
||||
localStorage.setItem("wishlist", JSON.stringify(wishlist));
|
||||
updateWishlistBadge();
|
||||
showNotification(`${name} added to wishlist!`, "success");
|
||||
} else {
|
||||
showNotification("Already in wishlist!", "info");
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Wishlist error:", e);
|
||||
showNotification("Added to wishlist!", "success");
|
||||
}
|
||||
}
|
||||
|
||||
function updateCartBadge() {
|
||||
try {
|
||||
const cart = JSON.parse(localStorage.getItem("cart") || "[]");
|
||||
const badge = document.querySelector(".cart-badge");
|
||||
if (badge) {
|
||||
const total = cart.reduce(
|
||||
(sum, item) => sum + (item.quantity || 1),
|
||||
0
|
||||
);
|
||||
badge.textContent = total;
|
||||
badge.style.display = total > 0 ? "flex" : "none";
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function updateWishlistBadge() {
|
||||
try {
|
||||
const wishlist = JSON.parse(localStorage.getItem("wishlist") || "[]");
|
||||
const badge = document.querySelector(".wishlist-badge");
|
||||
if (badge) {
|
||||
badge.textContent = wishlist.length;
|
||||
badge.style.display = wishlist.length > 0 ? "flex" : "none";
|
||||
}
|
||||
} catch (e) {}
|
||||
window.ShopSystem.addToWishlist({
|
||||
id: String(productId),
|
||||
name,
|
||||
price: parseFloat(price),
|
||||
imageurl,
|
||||
});
|
||||
}
|
||||
|
||||
function showNotification(message, type = "info") {
|
||||
@@ -1268,23 +1225,6 @@
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// Initialize badges on page load
|
||||
updateCartBadge();
|
||||
updateWishlistBadge();
|
||||
|
||||
function quickView(productId) {
|
||||
// Quick view modal logic
|
||||
alert("Quick view coming soon!");
|
||||
}
|
||||
|
||||
function updateCartCount() {
|
||||
// Handled by shopping manager
|
||||
}
|
||||
|
||||
function updateWishlistCount() {
|
||||
// Handled by shopping manager
|
||||
}
|
||||
|
||||
// Search functionality
|
||||
document
|
||||
.getElementById("productSearch")
|
||||
|
||||
Reference in New Issue
Block a user