-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcart.php
More file actions
101 lines (95 loc) · 4.44 KB
/
Copy pathcart.php
File metadata and controls
101 lines (95 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
require_once __DIR__ . '/includes/session_manager.php';
require_once __DIR__ . '/includes/dbh.php';
require_once __DIR__ . '/includes/products/product_model.php';
if (!isset($_SESSION["user_id"]) || !isset($_SESSION["user_role"]) || $_SESSION["user_role"] !== "user") {
header("Location: index.php");
exit;
}
$cartIds = array_keys($_SESSION['cart'] ?? []);
$products = [];
if (!empty($cartIds)) {
$products = getProductsByIds($pdo, $cartIds);
$totalPrice = 0;
foreach ($products as $product) {
$totalPrice += $product['price'];
}
}
?>
<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset='UTF-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="NotScam.com – nejlepší online platforma pro osobní růst a finanční svobodu. To určitě není podvod.">
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/print.css" media="print">
<link rel="icon" href="assets/img/iconlogo.png" type="image/png">
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;700&display=swap" rel="stylesheet">
<title>NotScam.com</title>
</head>
<body>
<header>
<div class="header__container">
<a href="index.php" class="logo">
<img class="logo__icon" src="assets/img/iconlogo.png" alt="icon logo">
<h1 class="logo__text">NotScam<span class="logo__smallerpart">.com</span></h1>
</a>
<nav>
<ul class="header__ul">
<li><a class="header__ul__link" href="index.php">Hlavní stránka</a></li>
<li><a class="header__ul__link" href="profile.php">Můj profil</a></li>
<li><a class="header__ul__link_chosen" href="cart.php">🛒Košík</a></li>
<li><a class="header__ul__link" href="logout.php">Odhlásit se</a></li>
</ul>
</nav>
<div id="burger" class="burger"><span></span></div>
<div id="burger-menu" class="burger__menu">
<nav>
<ul class="burger__ul">
<li><button id="burger-exitButton" class="burger__exitButton">×</button></li>
<li><a class="burger__ul__link" href="index.php">Hlavní stránka</a></li>
<li><a class="burger__ul__link" href="profile.php">Můj profil</a></li>
<li><a class="burger__ul__link_chosen" href="cart.php">🛒Košík</a></li>
<li><a class="burger__ul__link" href="logout.php">Odhlásit se</a></li>
</ul>
</nav>
</div>
</div>
</header>
<main class="cart">
<div class="cart__container">
<h1 class="cart__title">🛒 Košík</h1>
<?php if (empty($products)): ?>
<p class="cart__empty">Košík je prázdný</p>
<?php else: ?>
<?php foreach ($products as $product): ?>
<article class="cart-item">
<img
src="<?= $product['image_path']
? 'uploads/products/' . htmlspecialchars($product['image_path'])
: 'assets/img/no-image.png' ?>"
alt="<?= htmlspecialchars($product['name']) ?>"
>
<div class="cart-item__info">
<h2 class="cart-item__name"><?= htmlspecialchars($product['name']) ?></h2>
<p class="cart-item__price"><?= number_format($product['price'], 0, ',', ' ') ?> Kč</p>
<form method="post" action="includes/cart/remove_from_cart.php">
<input type="hidden" name="id" value="<?= $product['id'] ?>">
<button class="cart-item__removebtn" type="submit">Odebrat 🗑️</button>
</form>
</div>
</article>
<?php endforeach; ?>
<button class="cart__paybtn" type="button">
Zaplatit celkem <?= number_format($totalPrice, 0, ',', ' ') ?> Kč
</button>
<?php endif; ?>
</div>
</main>
<footer>
<p>© 2025 NotScam.com</p>
</footer>
<script src="assets/js/UI/burger.js"></script>
</body>
</html>