-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshop.html
433 lines (394 loc) · 18.7 KB
/
shop.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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Furniture</title>
<link rel="stylesheet" href="style.css">
<!-- bootstrap link -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<!-- bootstrap link -->
<!-- icons -->
<link href='https://unpkg.com/[email protected]/css/boxicons.min.css' rel='stylesheet'>
<!-- icons -->
</head>
<body>
<!-- navbar top -->
<div class="container">
<div class="navbar-top">
<div class="social-link">
<i><img src="./image/twitter.png" alt="" width="30px"></i>
<i><img src="./image/facebook.png" alt="" width="30px"></i>
<i><img src="./image/google-plus.png" alt="" width="30px"></i>
</div>
<div class="logo">
<h3><a href="/index.html" style="color: black;">FURNITURE</a></h3>
</div>
<div class="icons">
<i><img src="./image/search.png" alt="" width="20px"></i>
<i><img src="./image/heart.png" alt="" width="20px"></i>
<a href="cart.html"><i><img src="./image/shopping-cart.png" alt="" width="25px"></i></a>
</div>
</div>
</div>
<!-- navbar top -->
<!-- main content -->
<!-- <div class="main-content shop-content"> -->
<div class=" shop-content">
<nav class="navbar navbar-expand-md" id="navbar-color">
<div class="container">
<!-- Toggler/collapsibe Button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span><i><img src="./image/menu.png" alt="" width="30px"></i></span>
</button>
<!-- Navbar links -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="home.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="shop.html">Shop</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Top Chair</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Chair</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Brands</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#footer">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- <div class="content"> -->
<div class="shop_content">
<h1>Shop
</h1>
<!-- <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Repellendus minus modi illum cumque velit
consectetur?</p>
<span id="btn"><button><a href="sign-up.html">Signup</a></button></span>
<span id="btn"><button><a href="login.html">log In</a></button></span>
<span id="btn"><button><a href="login.html">Renovate a Room</a></button></span> -->
</div>
</div>
<!-- main content -->
<!-- card1 -->
<!-- <div class="container">
<h3 class="text-center" style="padding-top: 30px;">SERVICES WE OFFER</h3>
<div class="row" style="margin-top: 50px;">
<div class="col-md-4 py-3 py-md-0">
<div class="card">
<img src="./image/c1.png" alt="" class="card image-top img-fluid" height="200px">
<div class="card-body">
<h5 class="card-titel text-center">Ads</h5>
<p class="text-center">Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam ipsam
vitae facere eius modi iure possimus, soluta ea inventore. Omnis!</p>
<div id="btn2" class="text-center"><button>View More</button></div>
</div>
</div>
</div>
<div class="col-md-4 py-3 py-md-0">
<div class="card">
<img src="./image/c2.png" alt="" class="card image-top img-fluid" height="200px">
<div class="card-body">
<h5 class="card-titel text-center">3D Renovation</h5>
<p class="text-center">Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam ipsam
vitae facere eius modi iure possimus, soluta ea inventore. Omnis!</p>
<div id="btn2" class="text-center"><button>View More</button></div>
</div>
</div>
</div>
<div class="col-md-4 py-3 py-md-0">
<div class="card">
<img src="./image/c3.png" alt="" class="card image-top img-fluid" height="200px">
<div class="card-body">
<h5 class="card-titel text-center">Bartering System</h5>
<p class="text-center">Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam ipsam
vitae facere eius modi iure possimus, soluta ea inventore. Omnis!</p>
<div id="btn2" class="text-center"><button>View More</button></div>
</div>
</div>
</div>
</div>
</div> -->
<!-- card1 -->
<!-- card2 -->
<!-- <div class="container">
<div class="row" style="margin-top: 100px;">
<div class="col-md-4 py-3 py-md-0">
<div class="card" id="tpc">
<img src="./image/ch.png" alt="" class="card image-top img-fluid">
<div class="card-img-overlay">
<h4 class="card-titel">Best Chair</h4>
<p class="card-text">Lorem ipsum dolor.</p>
<div id="btn2"><button>View More</button></div>
</div>
</div>
</div>
<div class="col-md-4 py-3 py-md-0">
<div class="card" id="tpc">
<img src="./image/sf.png" alt="" class="card image-top img-fluid">
<div class="card-img-overlay">
<h4 class="card-titel">Sofa</h4>
<p class="card-text">Lorem ipsum dolor.</p>
<div id="btn2"><button>View More</button></div>
</div>
</div>
</div>
<div class="col-md-4 py-3 py-md-0">
<div class="card" id="tpc">
<img src="./image/work desk.png" alt="" class="card image-top img-fluid">
<div class="card-img-overlay">
<h4 class="card-titel">Work Desk</h4>
<p class="card-text">Lorem ipsum dolor.</p>
<div id="btn2"><button>View More</button></div>
</div>
</div>
</div>
</div>
</div> -->
<!-- card2 -->
<!-- card3 -->
<div class="container">
<!-- <h3 class="text-center" style="margin-top: 50px;">TREANDLY PRODUCTS</h3> -->
<div id="shop_products" class="row" style="margin-top: 50px;">
<!-- <div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/card1.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Best Sofa</h3>
<p class="card-text text-center">$1000.50</p>
<div id="btn3"><a href="cart.html"><button>Add to cart</button></a></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/card2.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Single Sofa</h3>
<p class="card-text text-center">$100.50</p>
<div id="btn3"><a href="cart.html"><button>Add to cart</button></a></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/card3.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Simple Chair</h3>
<p class="card-text text-center">$300.20</p>
<div id="btn3"><a href="cart.html"><button>Add to cart</button></a></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/card4.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Modern Chair</h3>
<p class="card-text text-center">$500.50</p>
<div id="btn3"><a href="cart.html"><button>Add to cart</button></a></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/Dining tables.jpg" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Dining Table</h3>
<p class="card-text text-center">$200.50</p>
<div id="btn3"><a href="cart.html"><button>Add to cart</button></a></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/work desk.png" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Work Desk</h3>
<p class="card-text text-center">$100.50</p>
<div id="btn3"><a href="cart.html"><button>Add to cart</button></a></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/Bookshelves.jpg" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Book Shelves</h3>
<p class="card-text text-center">$150.50</p>
<div id="btn3"><a href="cart.html"><button>Add to cart</button></a></div>
</div>
</div>
</div>
<div class="col-md-3 py-3 py-md-0">
<div class="card" id="c">
<img src="./image/bed.jpg" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-titel text-center">Bed</h3>
<p class="card-text text-center">$500.60</p>
<div id="btn3"><a href="cart.html"><button>Add to cart</button></a></div>
</div>
</div>
</div> -->
</div>
</div>
<!-- card3 -->
<!-- about -->
<!-- <div class="container">
<h1 class="text-center" style="margin-top: 50px;">ABOUT</h1>
<div class="row" style="margin-top: 50px;">
<div class="col-md-6 py-3 py-md-0">
<div class="card">
<img src="./image/about.png" alt="">
</div>
</div>
<div class="col-md-6 py-3 py-md-0">
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Laborum, saepe possimus quo, quasi animi
natus nulla beatae neque soluta pariatur id ducimus eum, sed quis enim minima? Fugiat delectus quo
optio nemo voluptatem ullam officiis neque exercitationem tenetur eum corporis quas in esse
blanditiis, quasi animi nam eos! Tempora deleniti eligendi magni ex voluptatum ut dicta nemo et
consequuntur distinctio quae atque porro inventore assumenda, nihil odio iusto accusamus libero
error nam aut, at praesentium cum reiciendis. Possimus consequatur obcaecati at illum in dolores
earum vero ipsum. Ipsam vitae adipisci corrupti totam vel consequuntur fugiat. Perferendis fuga
doloremque tempora, in eos, voluptates iure, optio qui modi ex ea saepe. Eum perspiciatis,
voluptates fugiat nesciunt corrupti minima aliquam repellat, ea quasi natus, recusandae aut nobis
modi. Commodi, alias reiciendis reprehenderit hic soluta consectetur corporis accusantium placeat,
totam minima nostrum magnam dolorum aut dolore, sapiente ea. Magni est quo ipsam nisi iste.</p>
<div id="btn4"><button>Read More...</button></div>
</div>
</div>
</div> -->
<!-- about -->
<!-- footer -->
<footer id="footer">
<h1 class="text-center">Furniture</h1>
<div class="icons text-center">
<i class="bx bxl-twitter"></i>
<i class="bx bxl-facebook"></i>
<i class="bx bxl-google"></i>
<i class="bx bxl-skype"></i>
<i class="bx bxl-instagram"></i>
</div>
<div class="copyright text-center">
© Copyright <strong><span>Furniture</span></strong>. All Rights Reserved
</div>
</footer>
<!-- footer -->
<script>
console.log("dadas")
const products = [
{
name: 'Best Sofa',
price: 1000.50,
image: './image/card1.png'
},
{
name: 'Single Sofa',
price: 100.50,
image: './image/card2.png'
},
{
name: 'Simple Chair',
price: 300.20,
image: './image/card3.png'
},
{
name: 'Modern Chair',
price: 500.50,
image: './image/card4.png'
},
{
name: 'Dining Table',
price: 200.50,
image: './image/Dining tables.jpg'
},
{
name: 'Work Desk',
price: 100.50,
image: './image/work desk.png'
},
{
name: 'Book Shelves',
price: 150.50,
image: './image/Bookshelves.jpg'
},
{
name: 'Bed',
price: 500.60,
image: './image/bed.jpg'
}
];
const cartItems = JSON.parse(localStorage.getItem('cartItems')) || [];
// Function to check if a product already exists in the cart
function isProductInCart(product) {
return cartItems.some(item => item.name === product.name);
}
// Function to handle the "Add to cart" button click
function addToCartButtonClick(event) {
const button = event.target;
const productName = button.getAttribute('data-name');
const productPrice = button.getAttribute('data-price');
const productImage = button.getAttribute('data-image');
// Create product object
const product = {
name: productName,
price: parseFloat(productPrice),
image: productImage
};
// Check if the product already exists in the cart
if (isProductInCart(product)) {
// Optionally, display a message indicating that the product is already in the cart
console.log('Product already in the cart');
return; // Exit the function to prevent adding duplicate items
}
// Add product to cart items
cartItems.push(product);
// Store updated cart items in localStorage
localStorage.setItem('cartItems', JSON.stringify(cartItems));
// Optionally, display a success message or perform any other actions
}
const container = document.querySelector('#shop_products');
// Map products array and generate HTML code
const productHTML = products.map(product => `
<div class="col-md-3 py-3 py-md-0">
<div class="card">
<img src="${product.image}" alt="" class="card image-top img-fluid">
<div class="card-body">
<h3 class="card-title text-center">${product.name}</h3>
<p class="card-text text-center">$${product.price.toFixed(2)}</p>
<div class="btn3">
<button class="add-to-cart-btn btn btn-outline-warning" data-name="${product.name}" data-price="${product.price}" data-image="${product.image}">Add to cart</button>
</div>
</div>
</div>
</div>
`).join('');
// Append the generated HTML code to the container
container.innerHTML = productHTML;
// Attach event listener to the "Add to cart" buttons
const addToCartButtons = document.querySelectorAll('.add-to-cart-btn');
addToCartButtons.forEach(button => {
button.addEventListener('click', addToCartButtonClick);
});
</script>
</body>
</html>