diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-06-01 16:02:10 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-06-01 16:02:10 +0200 |
commit | 879c72e50c172f6e20416dcf06fccdbb59525c7a (patch) | |
tree | d6cb693daa85b724eb3d07d8fae807b609cfd5c5 /public/cart.php | |
parent | 8af23ff155904ba78de61a3cdab33a048a0f5664 (diff) |
order from product catalogue and modify cart product count
Diffstat (limited to 'public/cart.php')
-rw-r--r-- | public/cart.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/public/cart.php b/public/cart.php index 60f4c63..ba33a9d 100644 --- a/public/cart.php +++ b/public/cart.php @@ -27,18 +27,24 @@ $cart_count = get_cart_count(); break; } + case "update": { + $statement = $cursor->prepare("update orderproduct set count = ? where product = ? and `order` = cart(?)"); + $statement->bind_param("iii", $_POST['count'], $_POST['product_id'], $user_id); + $statement->execute(); + return; // update requests are only triggered from JS and don't do anything with the response + } } } while (false); ?> <?php function item_template($item) { $image_path = $item->image ? "/img/product/$item->id-thumb.jpg" : "/img/placeholder.png"; echo <<<"EOF" - <div class="product"> + <div class="product" product-id="$item->id"> <img src="$image_path" alt="productafbeelding"> <span class="name">$item->name</span> <label for="$item->id-count">hoeveelheid:</label> - <input type="number" value="$item->count" min="1" max="20" id="$item->id-count" disabled> - <button type="submit" value="$item->id" name="product_id">weghalen</button> + <input type="number" value="$item->count" min="1" max="20" id="$item->id-count" class="count buttonstyle filled" disabled> + <button type="submit" value="$item->id" name="product_id" class="button outlined">weghalen</button> <span class="price">$item->price</span> </div> EOF; @@ -49,6 +55,7 @@ EOF; <?php include 'head.php' ?> <title>mand</title> <link rel="stylesheet" href="cart.css"> + <script defer src="cart.js"></script> </head> <body> <?php include 'navbar.php' ?> @@ -75,7 +82,7 @@ EOF; break; } echo <<<"EOF" - <form class="products" method="post"> + <form id="products" class="products" method="post"> <input type="hidden" name="type" value="delete"> EOF; while ($product = $res->fetch_object()) item_template($product); |