-
Notifications
You must be signed in to change notification settings - Fork 2
/
product-detail.php
389 lines (380 loc) · 14.9 KB
/
product-detail.php
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
<?php
require('services/connect.php');
$id = $_GET['id'];
$sql = "SELECT * FROM `products` WHERE id = $id";
$result = mysqli_query($connect, $sql);
$product = mysqli_fetch_array($result);
$id_manufacturer = $product['id_manufacturer'];
$sql = "SELECT * FROM `products` WHERE id_manufacturer = $id_manufacturer LIMIT 3";
$related_products = mysqli_query($connect, $sql);
?>
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<?php include('user/components/head.php') ?>
</head>
<body>
<!-- header start -->
<?php include('user/components/header.php') ?>
<!-- header end -->
<div class="breadcrumb-area">
<div class="container">
<div class="breadcrumb-content text-center">
<h2 class="text-dark">Chi tiết sản phẩm</h2>
</div>
</div>
</div>
<div class="product-details ptb-100 pb-90">
<div class="container">
<div class="row">
<div class="col-md-12 col-lg-7 col-12">
<div class="product-details-img-content">
<div class="product-details-tab mr-35 product-details-tab2">
<div class="product-details-small nav mr-10 product-details-2" role="tablist">
<a class="active mb-10" href="#pro-details1" data-toggle="tab" role="tab" aria-selected="true">
<img src="user/assets/img/product-details/s5.jpg" alt="" />
</a>
<a class="mb-10" href="#pro-details2" data-toggle="tab" role="tab" aria-selected="true">
<img src="user/assets/img/product-details/s6.jpg" alt="" />
</a>
<a class="mb-10" href="#pro-details3" data-toggle="tab" role="tab" aria-selected="true">
<img src="user/assets/img/product-details/s7.jpg" alt="" />
</a>
<a class="mb-10" href="#pro-details4" data-toggle="tab" role="tab" aria-selected="true">
<img src="user/assets/img/product-details/s8.jpg" alt="" />
</a>
</div>
<div class="product-details-large tab-content">
<div class="tab-pane active show fade" id="pro-details1" role="tabpanel">
<div class="easyzoom easyzoom--overlay is-ready">
<a href="user/assets/img/product-details/bl1.jpg">
<img src="public/images/<?php echo $product['image'] ?>" alt="" />
</a>
</div>
</div>
<div class="tab-pane fade" id="pro-details2" role="tabpanel">
<div class="easyzoom easyzoom--overlay is-ready">
<a href="user/assets/img/product-details/bl2.jpg">
<img src="public/images/<?php echo $product['image'] ?>" alt="" />
</a>
</div>
</div>
<div class="tab-pane fade" id="pro-details3" role="tabpanel">
<div class="easyzoom easyzoom--overlay is-ready">
<a href="user/assets/img/product-details/bl3.jpg">
<img src="public/images/<?php echo $product['image'] ?>" alt="" />
</a>
</div>
</div>
<div class="tab-pane fade" id="pro-details4" role="tabpanel">
<div class="easyzoom easyzoom--overlay is-ready">
<a href="user/assets/img/product-details/bl4.jpg">
<img src="public/images/<?php echo $product['image'] ?>" alt="" />
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12 col-lg-5 col-12">
<div class="product-details-content">
<h3><?php echo $product['name'] ?></h3>
<div class="rating-number">
<div class="quick-view-rating">
<i class="pe-7s-star red-star"></i>
<i class="pe-7s-star red-star"></i>
<i class="pe-7s-star"></i>
<i class="pe-7s-star"></i>
<i class="pe-7s-star"></i>
</div>
<div class="quick-view-number">
<span>2 Đánh giá</span>
</div>
</div>
<div class="details-price">
<span class="text-danger">Số lượng: <?php echo ($product['quantity']) ?></span>
</div>
<div class="details-price">
<span><?php echo number_format($product['price'] - ($product['price'] * $product['discount'] / 100)) ?>VND</span>
</div>
<p>
<?php echo ($product['description']) ?>
</p>
<div class="quickview-plus-minus">
<div class="quickview-btn-cart">
<a class="btn-add-to-cart btn-hover-black" href="#" data-id="<?php echo $product['id'] ?>">Thêm vào giỏ hàng</a>
</div>
</div>
<div class="product-details-cati-tag mt-35">
<ul>
<li class="categories-title">Danh mục:</li>
<li><a href="#">fashion</a></li>
<li><a href="#">electronics</a></li>
<li><a href="#">toys</a></li>
<li><a href="#">food</a></li>
<li><a href="#">jewellery</a></li>
</ul>
</div>
<div class="product-details-cati-tag mtb-10">
<ul>
<li class="categories-title">Tags :</li>
<li><a href="#">fashion</a></li>
<li><a href="#">electronics</a></li>
<li><a href="#">toys</a></li>
<li><a href="#">food</a></li>
<li><a href="#">jewellery</a></li>
</ul>
</div>
<div class="product-share">
<ul>
<li class="categories-title">Chia sẻ :</li>
<li>
<a href="#">
<i class="icofont icofont-social-facebook"></i>
</a>
</li>
<li>
<a href="#">
<i class="icofont icofont-social-twitter"></i>
</a>
</li>
<li>
<a href="#">
<i class="icofont icofont-social-pinterest"></i>
</a>
</li>
<li>
<a href="#">
<i class="icofont icofont-social-flikr"></i>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="product-description-review-area pb-90">
<div class="container">
<div class="product-description-review text-center">
<div class="description-review-title nav" role="tablist">
<a class="active" href="#pro-dec" data-toggle="tab" role="tab" aria-selected="true">Mô cả sản phẩm</a>
<a href="#pro-review" data-toggle="tab" role="tab" aria-selected="false"> Đánh giá (0) </a>
</div>
<div class="description-review-text tab-content">
<div class="tab-pane active show fade" id="pro-dec" role="tabpanel">
<p>
<?php echo $product['description'] ?>
</p>
</div>
<div class="tab-pane fade" id="pro-review" role="tabpanel">
<a href="#">Be the first to write your review!</a>
</div>
</div>
</div>
</div>
</div>
<!-- product area start -->
<div class="product-area pb-95">
<div class="container">
<div class="section-title-3 text-center mb-50">
<h2>Sản phẩm liên quan</h2>
</div>
<div class="product-style">
<div class="related-product-active owl-carousel">
<?php foreach ($related_products as $related_product) : ?>
<div class="product-wrapper">
<div class="product-img">
<a href="product-detail.php?id=<?php echo $related_product['id'] ?>">
<img src="public/images/<?php echo $related_product['image'] ?>" alt="" />
</a>
<span>hot</span>
<div class="product-action">
<a class="animate-left" title="Wishlist" href="#">
<i class="pe-7s-like"></i>
</a>
<a class="animate-top" title="Add To Cart" href="#">
<i class="pe-7s-cart"></i>
</a>
<a class="animate-right" title="Quick View" data-toggle="modal" data-target="#exampleModal" href="#">
<i class="pe-7s-look"></i>
</a>
</div>
</div>
<div class="product-content">
<h4><a href="product-detail.php?id=<?php echo $related_product['id'] ?>"><?php echo $related_product['name'] ?></a></h4>
<span><?php echo number_format($related_product['price'] - $related_product['price'] * $related_product['discount'] / 100) ?>VND</span>
</div>
</div>
<?php endforeach ?>
</div>
</div>
</div>
</div>
<!-- product area end -->
<?php include('user/components/footer.php') ?>
<!-- modal -->
<?php include('user/components/modal_product.php') ?>
<!-- modal -->
<div class="modal fade" id="exampleCompare" tabindex="-1" role="dialog" aria-hidden="true">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span class="pe-7s-close" aria-hidden="true"></span>
</button>
<div class="modal-dialog modal-compare-width" role="document">
<div class="modal-content">
<div class="modal-body">
<form action="#">
<div class="table-content compare-style table-responsive">
<table>
<thead>
<tr>
<th></th>
<th>
<a href="#">Remove <span>x</span></a>
<img src="user/assets/img/cart/4.jpg" alt="" />
<p>Blush Sequin Top</p>
<span>$75.99</span>
<a class="compare-btn" href="#">Add to cart</a>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="compare-title">
<h4>Description</h4>
</td>
<td class="compare-dec compare-common">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
beenin the stand ard dummy text ever since the 1500s, when an unknown printer took a galley
</p>
</td>
</tr>
<tr>
<td class="compare-title">
<h4>Sku</h4>
</td>
<td class="product-none compare-common">
<p>-</p>
</td>
</tr>
<tr>
<td class="compare-title">
<h4>Availability</h4>
</td>
<td class="compare-stock compare-common">
<p>In stock</p>
</td>
</tr>
<tr>
<td class="compare-title">
<h4>Weight</h4>
</td>
<td class="compare-none compare-common">
<p>-</p>
</td>
</tr>
<tr>
<td class="compare-title">
<h4>Dimensions</h4>
</td>
<td class="compare-stock compare-common">
<p>N/A</p>
</td>
</tr>
<tr>
<td class="compare-title">
<h4>brand</h4>
</td>
<td class="compare-brand compare-common">
<p>HasTech</p>
</td>
</tr>
<tr>
<td class="compare-title">
<h4>color</h4>
</td>
<td class="compare-color compare-common">
<p>Grey, Light Yellow, Green, Blue, Purple, Black</p>
</td>
</tr>
<tr>
<td class="compare-title">
<h4>size</h4>
</td>
<td class="compare-size compare-common">
<p>XS, S, M, L, XL, XXL</p>
</td>
</tr>
<tr>
<td class="compare-title"></td>
<td class="compare-price compare-common">
<p>$75.99</p>
</td>
</tr>
</tbody>
</table>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- all js here -->
<?php include('user/components/link_footer.php') ?>
<script>
function convertNumberToCurrency(number) {
const result = number.toLocaleString('it-IT', {
style: 'currency',
currency: 'VND'
})
return result;
}
$(document).ready(function() {
// thêm sản phẩm vào giỏ hàng
$(".btn-add-to-cart").click(function() {
let id = $(this).data('id');
$.ajax({
url: 'add_to_cart.php',
type: 'GET',
data: {
id
},
})
.done(function(response) {
if (response === 'add_to_cart_failed') {
$.notify('Số lượng trong giỏ hàng đã đạt tối đa', 'error');
} else if (response === 'product_out_of_stock') {
$.notify('Số lượng sản phẩm đã hết !', 'error');
} else {
$.notify(response + " vào giỏ hàng", "success");
}
})
})
// show modal chi tiết sản phẩm
$(".btn-view-detail").click(function() {
let id = $(this).data('id');
$.ajax({
url: 'view_detail_modal.php',
type: 'GET',
data: {
id
},
})
.done(function(response) {
const product = JSON.parse(response)
console.log(product['name'])
$(".title-modal").text(product['name']);
$(".title-price-old").text(convertNumberToCurrency(product['price']));
$(".title-price-new").text(convertNumberToCurrency(product['price'] - (product['price'] * product['discount'] / 100)));
$(".title-desc").text(product['description']);
$(".modal-image").attr("src", product['image']);
$(".modal-link").attr("href", `product-detail.php?id=${product['id']}`)
})
})
})
</script>
</body>
</html>