-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwishlist.php
More file actions
115 lines (100 loc) · 4.95 KB
/
Copy pathwishlist.php
File metadata and controls
115 lines (100 loc) · 4.95 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
$pageKey = 'wishlist';
$pageTitle = 'Wishlist | Zovita';
$pageDescription = 'Save your favorite Zovita products and organize future healthcare purchases in one place.';
$breadcrumbs = [
['label' => 'Home', 'url' => 'index.php'],
['label' => 'Wishlist']
];
require __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/products-data.php';
require_once __DIR__ . '/includes/store-state.php';
$defaultWishlistSlugs = array_map(
static function ($product) {
return $product['slug'];
},
array_slice(zvGetAllProducts(), 8, 9)
);
zvEnsureSessionWishlistSlugs($defaultWishlistSlugs);
$addSlug = zvSlugify($_GET['add'] ?? '');
if ($addSlug !== '' && zvFindProductBySlug($addSlug) !== null) {
$wishlistSlugs = zvGetSessionWishlistSlugs();
$wishlistSlugs[] = $addSlug;
zvSetSessionWishlistSlugs($wishlistSlugs);
header('Location: wishlist.php');
exit;
}
$removeParam = trim((string)($_GET['remove'] ?? ''));
if ($removeParam !== '') {
$removeSlugs = zvNormalizeSlugList(explode(',', $removeParam));
if ($removeSlugs !== []) {
zvRemoveSessionWishlistSlugs($removeSlugs);
}
header('Location: wishlist.php');
exit;
}
$wishlistItems = [];
foreach (zvGetSessionWishlistSlugs() as $slug) {
$item = zvFindProductBySlug($slug);
if ($item !== null) {
$wishlistItems[] = $item;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<?php require __DIR__ . '/includes/head.php'; ?>
<body class="zv-shell" data-page="wishlist">
<?php require __DIR__ . '/includes/navbar.php'; ?>
<?php require __DIR__ . '/includes/breadcrumbs.php'; ?>
<main class="zv-section-lg pb-12">
<div class="zv-container px-2 sm:px-3">
<section class="zv-hero p-6 sm:p-8 lg:p-10">
<span class="zv-chip">Saved products</span>
<h1 class="zv-page-title">Your wishlist</h1>
<p class="zv-page-lead">Keep important products ready for quick access, reordering, and cart movement.</p>
</section>
<section class="zv-section-lg" data-wishlist-root>
<div class="flex flex-wrap items-center justify-between gap-2">
<p class="text-sm font-semibold text-navy-800" data-wishlist-count></p>
<button type="button" class="zv-btn-secondary" data-remove-selected>Remove selected</button>
</div>
<div class="zv-product-grid mt-4">
<?php foreach ($wishlistItems as $item): ?>
<article
class="zv-product-card zv-product-card-premium"
data-wishlist-item
data-product-slug="<?php echo htmlspecialchars($item['slug'], ENT_QUOTES, 'UTF-8'); ?>">
<label class="zv-select-item-label">
<input type="checkbox" data-select-item>
<span>Select</span>
</label>
<a href="<?php echo htmlspecialchars($item['url'], ENT_QUOTES, 'UTF-8'); ?>" class="zv-product-link">
<div class="zv-product-image-wrap">
<img src="<?php echo htmlspecialchars($item['image'], ENT_QUOTES, 'UTF-8'); ?>" alt="<?php echo htmlspecialchars($item['name'], ENT_QUOTES, 'UTF-8'); ?>">
</div>
<div class="zv-product-meta">
<small><?php echo htmlspecialchars($item['sectionLabel'], ENT_QUOTES, 'UTF-8'); ?></small>
<strong><?php echo htmlspecialchars($item['name'], ENT_QUOTES, 'UTF-8'); ?></strong>
<p class="zv-product-price"><?php echo htmlspecialchars($item['priceLabel'], ENT_QUOTES, 'UTF-8'); ?></p>
</div>
</a>
<div class="zv-wishlist-actions mt-3">
<a href="cart.php?add=<?php echo rawurlencode($item['slug']); ?>" class="zv-btn-primary w-full">Add to cart</a>
<a href="wishlist.php?remove=<?php echo rawurlencode($item['slug']); ?>" class="zv-remove-btn w-full" data-remove-item>Remove</a>
</div>
</article>
<?php endforeach; ?>
</div>
<p class="zv-empty-state mt-4" data-wishlist-empty>Your wishlist is empty. Save products to view them here.</p>
<div class="mt-5 flex flex-wrap gap-3">
<a href="cart.php" class="zv-btn-primary">Move selected to cart</a>
<a href="shop-category-b.php" class="zv-btn-secondary">Browse more products</a>
</div>
</section>
</div>
</main>
<?php require __DIR__ . '/includes/footer.php'; ?>
<?php require __DIR__ . '/includes/scripts.php'; ?>
</body>
</html>