forked from Tejashri-Taral/TrendTrove-Ecommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.html
345 lines (308 loc) · 8.17 KB
/
cart.html
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TrendTrove</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f7f7f7;
margin: 0;
padding: 0;
}
.container {
width: 90%;
margin: 40px auto;
display: flex;
justify-content: space-between;
}
.cart-items {
width: 65%;
height: 80vh;
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
}
.cart-item {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #e0e0e0;
padding: 15px 0;
}
.cart-item img {
width: 80px;
height: 80px;
border-radius: 10px;
object-fit: cover;
}
.item-details {
width: 60%;
}
.item-details h4 {
margin: 0;
font-size: 16px;
font-weight: bold;
}
.item-details p {
margin: 5px 0;
color: #555;
}
.item-quantity {
display: flex;
align-items: center;
}
.item-quantity button {
background-color: #000;
color: #fff;
border: none;
padding: 5px 10px;
font-size: 16px;
cursor: pointer;
border-radius: 5px;
}
.item-quantity input {
width: 40px;
text-align: center;
margin: 0 10px;
font-size: 16px;
}
.cart-summary {
width: 30%;
background: #f0f0f0;
border-radius: 10px;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.cart-summary h2 {
font-size: 18px;
font-weight: bold;
}
.summary-item {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
}
.summary-item span {
font-size: 16px;
}
.total-price {
font-size: 18px;
font-weight: bold;
}
.checkout-btn {
width: 100%;
padding: 10px;
background-color: #000;
color: #fff;
border: none;
font-size: 16px;
cursor: pointer;
border-radius: 5px;
text-align: center;
}
.checkout-btn:hover {
background-color: #333;
}
.back-to-shop {
text-align: left;
margin-top: 20px;
font-size: 16px;
color: #333;
text-decoration: none;
}
.back-to-shop:hover {
text-decoration: underline;
}
/* General styling for the cart */
.shopping-cart {
display: flex;
justify-content: space-between;
padding: 20px;
}
.cart-items {
width: 60%;
}
.item {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #ccc;
}
.cart-summary {
width: 30%;
padding: 20px;
background-color: #f5f5f5;
border-radius: 8px;
}
.cart-summary h3 {
text-align: center;
margin-bottom: 20px;
}
.summary-item {
margin-bottom: 15px;
display: flex;
justify-content: space-between;
align-items: center;
}
#shipping-method {
padding: 5px;
width: 100%;
}
#give-code {
padding: 5px;
width: 100%;
border: 1px solid #ccc;
border-radius: 4px;
}
.checkout-button {
width: 100%;
padding: 10px;
background-color: #000;
color: #fff;
border: none;
cursor: pointer;
font-size: 16px;
border-radius: 4px;
}
.checkout-button:hover {
background-color: #444;
}
#total-price {
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<div class="cart-items">
<h2>TrendTrove Cart</h2>
<div class="cart-item">
<img src="images/shop-bags.webp" alt="T-shirt">
<div class="item-details">
<h4>Accessory</h4>
<p>Shop Bag</p>
</div>
<div class="item-quantity">
<button onclick="decreaseQuantity(0)">-</button>
<input type="number" value="1" id="quantity-0">
<button onclick="increaseQuantity(0)">+</button>
</div>
<p>€344.00</p>
<button onclick="removeItem(0)">×</button>
</div>
<div class="cart-item">
<img src="images/shop-sandals.webp" alt="T-shirt">
<div class="item-details">
<h4>Shoe Wear</h4>
<p>Sandals</p>
</div>
<div class="item-quantity">
<button onclick="decreaseQuantity(1)">-</button>
<input type="number" value="1" id="quantity-1">
<button onclick="increaseQuantity(1)">+</button>
</div>
<p>744.00</p>
<button onclick="removeItem(1)">×</button>
</div>
<div class="cart-item">
<img src="images/insta1.webp" alt="Clothes">
<div class="item-details">
<h4>Dress</h4>
<p>Frock</p>
</div>
<div class="item-quantity">
<button onclick="decreaseQuantity(2)">-</button>
<input type="number" value="1" id="quantity-2">
<button onclick="increaseQuantity(2)">+</button>
</div>
<p>4400.00</p>
<button onclick="removeItem(2)">×</button>
</div>
<div class="cart-item">
<img src="images/product1-effect.jpg" alt="Clothes">
<div class="item-details">
<h4>Dress</h4>
<p>Fashion Wear</p>
</div>
<div class="item-quantity">
<button onclick="decreaseQuantity(2)">-</button>
<input type="number" value="1" id="quantity-2">
<button onclick="increaseQuantity(2)">+</button>
</div>
<p>€1400.00</p>
<button onclick="removeItem(2)">×</button>
</div>
<a href="index.html" class="back-to-shop">← Back to shop</a>
</div>
<div class="cart-summary">
<h3>Summary</h3>
<div class="summary-item">
<p>Items <span id="item-count">0</span></p>
</div>
<div class="summary-item">
<p>Shipping</p>
<select id="shipping-method" onchange="updateTotal()">
<option value="5">Standard Delivery - €5.00</option>
<option value="10">Express Delivery - €10.00</option>
</select>
</div>
<div class="summary-item">
<p>Give Code</p>
<input type="text" id="give-code" placeholder="Enter your code" />
</div>
<div class="summary-item">
<p>Total Price <span id="total-price">€0.00</span></p>
</div>
<button class="checkout-button" onclick="checkout()">CHECKOUT</button>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
updateSummary();
});
const itemPrices = [344.00, 744.00, 4400.00, 1400.00];
let quantities = [1, 1, 1, 1];
function updateSummary() {
let totalItems = 0;
let totalItemsPrice = 0;
for (let i = 0; i < quantities.length; i++) {
totalItems += quantities[i];
totalItemsPrice += quantities[i] * itemPrices[i];
}
const shippingCost = parseFloat(document.getElementById('shipping-method').value);
const totalPrice = totalItemsPrice + shippingCost;
document.getElementById('item-count').textContent = totalItems;
document.getElementById('total-price').textContent = '€' + totalPrice.toFixed(2);
}
function increaseQuantity(index) {
quantities[index]++;
document.getElementById(`quantity-${index}`).value = quantities[index];
updateSummary();
}
function decreaseQuantity(index) {
if (quantities[index] > 1) {
quantities[index]--;
document.getElementById(`quantity-${index}`).value = quantities[index];
updateSummary();
}
}
function removeItem(index) {
document.querySelectorAll('.cart-item')[index].remove();
itemPrices.splice(index, 1);
quantities.splice(index, 1);
updateSummary();
}
function checkout() {
alert('Proceeding to checkout with total price: ' + document.getElementById('total-price').textContent);
}
function updateTotal() {
updateSummary();
}
updateSummary();
</script>
</body>
</html>