From 04707c5f81e0b5e4b94e474d72b715582fd2c33d Mon Sep 17 00:00:00 2001
From: totoW <anthony.weiss1910@gmail.com>
Date: Thu, 11 Jan 2024 17:46:06 +0100
Subject: [PATCH] shopping cart changes

---
 startbootstrap-agency-gh-pages/index.php | 28 ++++++------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/startbootstrap-agency-gh-pages/index.php b/startbootstrap-agency-gh-pages/index.php
index e81613c..189704b 100644
--- a/startbootstrap-agency-gh-pages/index.php
+++ b/startbootstrap-agency-gh-pages/index.php
@@ -342,9 +342,13 @@ include("../html/data_treatment/connect_database.php");
                                         <input type="text" value="1" <?php echo 'id="quantity"'.$i; ?>>
                                         <button onclick="incrementQuantity(this)">+</button>
                                     </div>
-                                    <button class="btn btn-primary btn-xl text-uppercase" type="button" <?php echo 'id = "buttonShoppingCart'.$i.'"';?>>
-                                        Add to shopping cart
-                                    </button>
+                                    <button class="btn btn-primary btn-xl text-uppercase" type="button" 
+                                            data-item-id="<?php echo $i; ?>"
+                                            data-item-name="<?php echo $articles[$i]["itemName"]; ?>"
+                                            data-item-price="<?php echo $articles[$i]["price"]; ?>"
+                                            onclick="addToCart(this)">
+                                            Add to shopping cart
+                                        </button>
 
                                     <script>
                                         function incrementQuantity(button) {
@@ -418,24 +422,6 @@ include("../html/data_treatment/connect_database.php");
         <script src="https://cdn.startbootstrap.com/sb-forms-latest.js"></script>
         <script src="js/slideBox.js"></script>
         <script>
-            
-            function incrementQuantity(button) {
-                var input = button.parentNode.querySelector('input');
-                var value = parseInt(input.value, 10);
-                input.value = value + 1;
-            }
-
-            function decrementQuantity(button) {
-                var input = button.parentNode.querySelector('input');
-                var value = parseInt(input.value, 10);
-                if (value > 0) {
-                    input.value = value - 1;
-                }
-            }
-            function removeProduct(button) {
-                var product = button.parentNode.parentNode;
-                product.parentNode.removeChild(product);
-        }
             function updateOnlineUsers() {
             $.ajax({
                 url: '../html/data_treatment/AJAX/online_Users.php',
-- 
GitLab