aboutsummaryrefslogtreecommitdiff
path: root/public/cart.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/cart.php')
-rw-r--r--public/cart.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/public/cart.php b/public/cart.php
index ba33a9d..f7ee295 100644
--- a/public/cart.php
+++ b/public/cart.php
@@ -38,6 +38,7 @@
<?php
function item_template($item) {
$image_path = $item->image ? "/img/product/$item->id-thumb.jpg" : "/img/placeholder.png";
+ $price = number_format($item->price, 2, ',', '.');
echo <<<"EOF"
<div class="product" product-id="$item->id">
<img src="$image_path" alt="productafbeelding">
@@ -45,7 +46,7 @@ function item_template($item) {
<label for="$item->id-count">hoeveelheid:</label>
<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>
+ <span class="price">$price</span>
</div>
EOF;
}
@@ -86,8 +87,17 @@ EOF;
<input type="hidden" name="type" value="delete">
EOF;
while ($product = $res->fetch_object()) item_template($product);
+
+ $statement = $cursor->prepare("select cart_sum(cart(?)) as `sum`");
+ $statement->bind_param("i", $user_id);
+ if (!$statement->execute()) break;
+ $res = $statement->get_result();
+ $subtotal = number_format($res->fetch_object()->sum, 2, ',', '.');
echo <<<"EOF"
</form>
+ <div class="alignright">
+ <span class="sum">Subtotaal: <span class="subtotal price">$subtotal</span></span>
+ </div>
<form class="product-footer" method="post" action="/order-complete.php">
<input type="submit" value="Bestellen" class="buttonstyle filled">
</form>