cart.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. require_once __DIR__ . '/config.php';
  3. require_once __DIR__ . '/includes/functions.php';
  4. $pageTitle = 'Warenkorb';
  5. if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['remove_item_index'])) {
  6. removeCartItemByIndex((int) $_POST['remove_item_index']);
  7. }
  8. $cartItems = getCartItemsDetailed();
  9. include __DIR__ . '/includes/header.php';
  10. ?>
  11. <h2>Warenkorb</h2>
  12. <?php if (empty($cartItems)): ?>
  13. <div class="alert alert-info">
  14. <p>Ihr Warenkorb ist leer.</p>
  15. <a href="index.php" class="btn">Weiter zur Produktübersicht</a>
  16. </div>
  17. <?php else: ?>
  18. <?php foreach ($cartItems as $cartItem): ?>
  19. <div class="cart-item">
  20. <div class="cart-item-info">
  21. <h3><?php echo escape($cartItem['product']['name']); ?></h3>
  22. <?php if ($cartItem['size'] !== ''): ?>
  23. <p><strong>Größe:</strong> <?php echo escape($cartItem['size']); ?></p>
  24. <?php endif; ?>
  25. <?php if ($cartItem['availability_label'] !== ''): ?>
  26. <p><strong>Lieferhinweis:</strong> <?php echo escape($cartItem['availability_label']); ?></p>
  27. <?php endif; ?>
  28. <p><strong>Menge:</strong> 1</p>
  29. </div>
  30. <div class="cart-item-actions">
  31. <form method="POST">
  32. <button type="submit" name="remove_item_index" value="<?php echo (int) $cartItem['cart_index']; ?>" class="btn btn-secondary btn-small">Entfernen</button>
  33. </form>
  34. </div>
  35. </div>
  36. <?php endforeach; ?>
  37. <div class="cart-actions">
  38. <div class="cart-total">Artikel im Warenkorb: <?php echo count($cartItems); ?></div>
  39. <div class="cart-buttons">
  40. <a href="index.php" class="btn btn-secondary">Weiter auswählen</a>
  41. <a href="checkout.php" class="btn">Zur Bestellung</a>
  42. </div>
  43. </div>
  44. <?php endif; ?>
  45. <?php include __DIR__ . '/includes/footer.php'; ?>