| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- require_once __DIR__ . "/config.php";
- require_once __DIR__ . "/includes/functions.php";
- $pageTitle = "Warenkorb";
- if (
- $_SERVER['REQUEST_METHOD'] === "POST" &&
- isset($_POST['remove_item_index'])
- ) {
- // Validate CSRF token
- if (validateCsrfToken($_POST['csrf_token'] ?? "")) {
- removeCartItemByIndex((int) $_POST['remove_item_index']);
- }
- }
- $cartItems = getCartItemsDetailed();
- $cartNotice = consumeFlashMessage("cart_notice");
- include __DIR__ . "/includes/header.php";
- ?>
- <h2>Warenkorb</h2>
- <?php if ($cartNotice !== null): ?>
- <div class="alert alert-<?php echo escape($cartNotice["type"]); ?>">
- <?php echo escape($cartNotice["message"]); ?>
- </div>
- <?php endif; ?>
- <?php if (empty($cartItems)): ?>
- <div class="alert alert-info">
- <p>Ihr Warenkorb ist leer.</p>
- <a href="index.php" class="btn">Weiter zur Produktübersicht</a>
- </div>
- <?php else: ?>
- <?php foreach ($cartItems as $cartItem): ?>
- <div class="cart-item">
- <div class="cart-item-info">
- <h3><?php echo escape($cartItem["product"]["name"]); ?></h3>
- <?php if ($cartItem["size"] !== ""): ?>
- <p><strong>Größe:</strong> <?php echo escape(
- $cartItem["size"],
- ); ?></p>
- <?php endif; ?>
- <?php if ($cartItem["availability_label"] !== ""): ?>
- <p><strong>Lieferhinweis:</strong> <?php echo escape(
- $cartItem["availability_label"],
- ); ?></p>
- <?php endif; ?>
- </div>
- <div class="cart-item-actions">
- <form method="POST">
- <?php echo csrfField(); ?>
- <button type="submit" name="remove_item_index" value="<?php echo (int) $cartItem[
- "cart_index"
- ]; ?>" class="btn btn-secondary btn-small">Entfernen</button>
- </form>
- </div>
- </div>
- <?php endforeach; ?>
- <div class="cart-actions">
- <div class="cart-buttons">
- <a href="index.php" class="btn btn-secondary">Weiter auswählen</a>
- <a href="checkout.php" class="btn">Zur Bestellung</a>
- </div>
- </div>
- <?php endif; ?>
- <?php include __DIR__ . "/includes/footer.php"; ?>
|