-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcart.html
More file actions
241 lines (202 loc) · 9.48 KB
/
Copy pathcart.html
File metadata and controls
241 lines (202 loc) · 9.48 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Cart | Fawaz Fragrance</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Baskervville:ital@0;1&display=swap" rel="stylesheet">
<script src="https://unpkg.com/lenis@1.0.45/dist/lenis.min.js"></script>
<style>
/* --- CORE STYLES --- */
:root {
--bg-cream: #F8F5F0; --text-dark-brown: #3E2B26; --bar-brown: #A68B6C;
--box-beige: #F4EFE6; --btn-text: #FFFFFF;
--nav-pill-dark: #BCA380; --nav-item-light: #DBCDBA;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background-color: var(--bg-cream); color: var(--text-dark-brown); font-family: 'Cambria', serif; padding-bottom: 100px; }
/* --- HEADER --- */
.cart-header {
display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
padding: 20px 25px;
}
.back-circle-btn {
width: 40px; height: 40px; border-radius: 50%; background-color: #A68B6C;
display: flex; align-items: center; justify-content: center; cursor: pointer; border: none;
color: white; font-size: 20px;
}
.page-title { font-size: 24px; font-weight: 600; font-family: 'Baskervville', serif; text-align: center; }
/* --- CART ITEMS --- */
.cart-container { padding: 20px 25px; max-width: 600px; margin: 0 auto; }
.item-count-label { font-size: 18px; margin-bottom: 20px; font-family: 'Baskervville', serif; }
.cart-item {
display: flex; align-items: center; gap: 15px; margin-bottom: 20px;
}
.item-img {
width: 80px; height: 80px; background-color: #D9D9D9; border-radius: 12px;
object-fit: cover;
}
.item-details { flex: 1; }
.item-name { font-weight: 700; font-size: 16px; margin-bottom: 4px; font-family: 'Baskervville', serif; }
.item-tag { font-size: 12px; color: #888; margin-bottom: 4px; }
.item-price { font-weight: 700; font-size: 16px; color: #3E2B26; }
.qty-controls { display: flex; align-items: center; gap: 10px; }
.qty-btn {
width: 28px; height: 28px; border-radius: 50%; background-color: #A68B6C;
color: white; border: none; display: flex; align-items: center; justify-content: center;
font-size: 18px; cursor: pointer;
}
.qty-number { font-weight: 600; font-size: 16px; min-width: 20px; text-align: center; }
/* --- ACTION BUTTONS --- */
.cart-actions { display: flex; flex-direction: column; gap: 15px; margin-top: 40px; }
.btn-outline {
width: 100%; padding: 15px; border-radius: 30px; border: 1px solid #A68B6C;
background: transparent; color: #A68B6C; font-weight: 600; font-family: 'Baskervville', serif;
cursor: pointer; text-align: center; text-decoration: none; display: block;
}
.btn-filled {
width: 100%; padding: 15px; border-radius: 30px; border: none;
background: #A68B6C; color: white; font-weight: 600; font-family: 'Baskervville', serif;
cursor: pointer; box-shadow: 0 4px 10px rgba(166, 139, 108, 0.3);
text-align: center;
text-decoration: none;
}
/* --- BOTTOM NAV (Matches your design) --- */
.bottom-nav-pill {
position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
background-color: #BCA380; border-radius: 50px; padding: 10px 12px;
display: flex; align-items: center; gap: 15px;
box-shadow: 0 5px 15px rgba(0,0,0,0.3); z-index: 2000;
}
.nav-circle-btn {
width: 42px; height: 42px; border-radius: 50%; background-color: #DBCDBA;
display: flex; align-items: center; justify-content: center; border: none; cursor: pointer;
text-decoration: none;
}
.nav-circle-btn img { width: 20px; opacity: 0.6; }
/* Active State for Cart Page */
.nav-active-pill {
background-color: #FFFFFF; border-radius: 30px; padding: 8px 20px;
display: flex; align-items: center; gap: 8px; height: 42px;
}
.nav-active-pill span { font-family: 'Cambria', serif; font-size: 16px; color: var(--text-dark-brown); }
.nav-active-pill img { width: 18px; }
/* Empty State */
#emptyCartMsg { text-align: center; margin-top: 50px; color: #888; display: none; }
html.lenis, html.lenis body {
height: auto;
}
.lenis.lenis-smooth {
scroll-behavior: auto !important;
}
.lenis.lenis-smooth [data-lenis-prevent] {
overscroll-behavior: contain;
}
.lenis.lenis-stopped {
overflow: hidden;
}
.lenis.lenis-scrolling iframe {
pointer-events: none;
}
</style>
</head>
<body>
<div class="cart-header">
<button class="back-circle-btn" onclick="history.back()">←</button>
<div class="page-title">Cart</div>
<div></div> </div>
<div class="cart-container">
<div class="item-count-label" id="itemCountLabel">Item (0)</div>
<div id="cartItemsList"></div>
<div id="emptyCartMsg">Your cart is empty.</div>
<div class="cart-actions" id="cartActions">
<a class='btn-outline' href='collection.html'>Continue Shopping</a>
<a class='btn-filled' href='checkout.html'>Checkout Now</a>
</div>
</div>
<div class="bottom-nav-pill">
<a class='nav-circle-btn' href='index.html'>
<img src="./assets/icons/home.svg" alt="Home">
</a>
<a class='nav-circle-btn' href='collection.html'>
<img src="./assets/icons/perfumes.svg" alt="Bag">
</a>
<div class="nav-active-pill">
<img src="./assets/icons/kallu-cart.svg" alt="Cart">
<span>Cart</span>
</div>
</div>
<script>
// Helper to format numbers back to currency string
function formatCurrency(amount) {
return "Rs. " + amount;
}
function loadCart() {
let cart = JSON.parse(localStorage.getItem('fawazCart')) || [];
const list = document.getElementById('cartItemsList');
const countLabel = document.getElementById('itemCountLabel');
const emptyMsg = document.getElementById('emptyCartMsg');
const actions = document.getElementById('cartActions');
list.innerHTML = '';
// --- FIX 2: Calculate Total Item Count (Sum of Quantities) ---
const totalItemCount = cart.reduce((sum, item) => sum + item.quantity, 0);
countLabel.innerText = `Item (${totalItemCount})`;
if (cart.length === 0) {
emptyMsg.style.display = 'block';
actions.style.display = 'none';
return;
} else {
emptyMsg.style.display = 'none';
actions.style.display = 'flex';
}
cart.forEach((product, index) => {
// --- FIX 3: Calculate Price Totals ---
// Ensure price is a number, then multiply by quantity
const unitPrice = Number(product.price);
const rowTotal = unitPrice * product.quantity;
const displayPrice = formatCurrency(rowTotal);
const row = document.createElement('div');
row.classList.add('cart-item');
row.innerHTML = `
<img src="${product.img}" alt="${product.name}" class="item-img">
<div class="item-details">
<div class="item-name">${product.name}</div>
<div class="item-tag">${product.tagline || 'Fragrance'}</div>
<div class="item-price">${displayPrice}</div> </div>
<div class="qty-controls">
<button class="qty-btn" onclick="updateQty(${index}, -1)">-</button>
<span class="qty-number">${product.quantity}</span>
<button class="qty-btn" onclick="updateQty(${index}, 1)">+</button>
</div>
`;
list.appendChild(row);
});
}
function updateQty(index, change) {
let cart = JSON.parse(localStorage.getItem('fawazCart')) || [];
cart[index].quantity += change;
// Remove item if quantity goes to 0
if (cart[index].quantity <= 0) {
cart.splice(index, 1);
}
localStorage.setItem('fawazCart', JSON.stringify(cart));
loadCart(); // Refresh UI
}
// Initialize
document.addEventListener('DOMContentLoaded', loadCart);
// Initialize Lenis
const lenis = new Lenis({
duration: 2, // Higher number = slower/smoother scroll (default is 1)
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
smooth: true
});
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
</script>
</body>
</html>