58 lines
2.3 KiB
PHP
58 lines
2.3 KiB
PHP
<!-- 8. views/cart.php - Vue panier basique -->
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Mon Panier - <?= SITE_NAME ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
</head>
|
|
<body>
|
|
<div class="container py-4">
|
|
<h1>Mon Panier</h1>
|
|
|
|
<?php if (empty($_SESSION['cart'] ?? [])): ?>
|
|
<div class="alert alert-info">Votre panier est vide.</div>
|
|
<a href="<?= BASE_URL ?>" class="btn btn-primary">Continuer vos achats</a>
|
|
<?php else: ?>
|
|
<div class="table-responsive">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Produit</th>
|
|
<th>Quantité</th>
|
|
<th>Prix unitaire</th>
|
|
<th>Total</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$total = 0;
|
|
foreach ($_SESSION['cart'] as $item):
|
|
$itemTotal = $item['price'] * $item['quantity'];
|
|
$total += $itemTotal;
|
|
?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($item['name']) ?></td>
|
|
<td><?= $item['quantity'] ?></td>
|
|
<td><?= number_format($item['price'], 2) ?> €</td>
|
|
<td><?= number_format($itemTotal, 2) ?> €</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
<tfoot>
|
|
<tr>
|
|
<th colspan="3" class="text-end">Total général :</th>
|
|
<th><?= number_format($total, 2) ?> €</th>
|
|
</tr>
|
|
</tfoot>
|
|
</table>
|
|
</div>
|
|
<div class="d-flex gap-2">
|
|
<a href="<?= BASE_URL ?>" class="btn btn-secondary">Continuer les achats</a>
|
|
<button class="btn btn-success">Procéder au paiement</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</body>
|
|
</html>
|