This commit is contained in:
Dylanomz
2025-02-13 12:20:21 +01:00
parent 05d15fab69
commit 462cd5f206
4 changed files with 104 additions and 4 deletions

View File

@@ -1,6 +1,10 @@
// Array to hold items added to the shopping cart
const cart = [];
// Functie om een item aan het winkelwagentje toe te voegen
function addToCart(item) {
cart.unshift(item); // Add item to the beginning of the cart array
@@ -8,6 +12,8 @@ function addToCart(item) {
closeModal();
}
// Functie om het winkelwagentje bij te werken
function updateCart() {
const cartItemsContainer = document.getElementById("cart-items");
@@ -35,6 +41,7 @@ function updateCart() {
}
}
// Functie om een item uit het winkelwagentje te verwijderen
function removeFromCart(index) {
cart.splice(index, 1);
@@ -43,3 +50,15 @@ function removeFromCart(index) {
// Initial call to updateCart to ensure the button is hidden on page load
updateCart();
// Functie om het modaal venster te sluiten
function closeModal() {
document.getElementById('modal').style.display = 'none';
}
let cartCount = 0;
function addToCart() {
cartCount++;
document.querySelector('.cart-count').textContent = cartCount;
}