prepare("delete from orderproduct where product = ? and `order` = cart(?)"); $statement->bind_param("ii", $_POST['product_id'], $user_id); $statement->execute(); $cart_count = get_cart_count(); break; } case "add": { // ik wou deze functie eigenlijk in een stored procedure doen maar het // schijnt dat de knappe koppen bij mysql het geen goed idee vonden om // gewoon 'return' toe te staan binnen de body van een stored // procedure??? $statement = $cursor->prepare("select add_to_cart(?, ?)"); $statement->bind_param("ii", $_POST['product_id'], $user_id); $statement->execute(); $statement->get_result()/*->fetch_object()*/; $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); ?> image ? "/img/product/$item->id-thumb.jpg" : "/img/placeholder.png"; $price = number_format($item->price, 2, ',', '.'); echo <<<"EOF"
productafbeelding $item->name $price
EOF; } ?> mand
EOF; } while (false); ?>

dingen in de mand van

prepare("select product.id, product.name, product.price, product.image, orderproduct.count from orderproduct join product on product.id = orderproduct.product where `order` = cart(?)"); $statement->bind_param("i", $user_id); if (!$statement->execute()) break; $res = $statement->get_result(); if (!mysqli_num_rows($res)) { echo "mandje leeg"; break; } echo <<<"EOF"
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"
Subtotaal: $subtotal
EOF; } while (false); ?>