mirror of
https://github.com/Alvin-Zilverstand/Schoolkantine.git
synced 2026-03-06 21:36:27 +01:00
k
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user