dntr228 commited on
Commit
b611bcc
·
verified ·
1 Parent(s): 3daaa3c

Функция добавления чита в корзину сломана, почини её

Browse files
Files changed (1) hide show
  1. index.html +13 -10
index.html CHANGED
@@ -448,20 +448,23 @@
448
  setTimeout(() => toast.remove(), 2000);
449
  }
450
 
451
- // Attach listeners to all "add to cart" buttons
452
- document.querySelectorAll('.add-to-cart').forEach(btn => {
453
- btn.addEventListener('click', () => {
454
- const product = btn.dataset.product;
455
- const price = btn.dataset.price;
456
- addToCart(product, price);
 
 
 
457
  });
458
- });
459
 
460
- // Initialize
461
- updateCartCount();
 
462
 
463
  // Initialize feather icons
464
  feather.replace();
465
- </script>
466
  </body>
467
  </html>
 
448
  setTimeout(() => toast.remove(), 2000);
449
  }
450
 
451
+ // Initialize cart functionality after DOM is loaded
452
+ document.addEventListener('DOMContentLoaded', function() {
453
+ // Attach listeners to all "add to cart" buttons
454
+ document.querySelectorAll('.add-to-cart').forEach(btn => {
455
+ btn.addEventListener('click', function() {
456
+ const product = this.dataset.product;
457
+ const price = this.dataset.price;
458
+ addToCart(product, price);
459
+ });
460
  });
 
461
 
462
+ // Initialize cart count
463
+ updateCartCount();
464
+ });
465
 
466
  // Initialize feather icons
467
  feather.replace();
468
+ </script>
469
  </body>
470
  </html>