aboutsummaryrefslogtreecommitdiff
path: root/public/cart.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/cart.php')
-rw-r--r--public/cart.php15
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);