forked from sajjadsaleem341/Plant-Nest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
product.php
359 lines (338 loc) · 19.1 KB
/
product.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
<?php
include 'header.php';
$product_id = mysqli_real_escape_string($con,$_GET['id']);
if($product_id>0){
$get_product = get_product($con,'','',$product_id);
}
else{
echo "<script>window.location.href='index.php'</script>";
}
// Check if the content is favorited by the user
$is_favorited = false;
if (isset($_SESSION['USER_LOGIN'])) {
$user_id = $_SESSION['USER_ID'];
$sql_check_favorite = mysqli_query($con, "SELECT * FROM wishlist WHERE user_id = $user_id AND product_id = $product_id");
if (mysqli_num_rows($sql_check_favorite) > 0) {
$is_favorited = true;
}
}
?>
<!-- ##### Breadcrumb Area Start ##### -->
<div class="breadcrumb-area">
<!-- Top Breadcrumb Area -->
<div class="top-breadcrumb-area bg-img bg-overlay d-flex align-items-center justify-content-center"
style="background-image: url(img/bg-img/24.jpg);">
<h2>Product Details</h2>
</div>
<div class="container">
<div class="row">
<div class="col-12">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/index.php"><i class="fa fa-home"></i> Home</a></li>
<li class="breadcrumb-item"><a href="/shop.php">Shop</a></li>
<li class="breadcrumb-item active" aria-current="page">product details</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
<!-- ##### Breadcrumb Area End ##### -->
<!-- ##### Single Product Details Area Start ##### -->
<section class="single_product_details_area mb-50">
<div class="produts-details--content mb-50">
<div class="container">
<div class="row justify-content-between">
<div class="col-12 col-md-6 col-lg-5">
<div class="single_product_thumb">
<div id="product_details_slider" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="./image/<?= $get_product['0']['Image'] ?>" alt="1">
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-6">
<div class="single_product_desc">
<h4 class="title"><?= $get_product['0']['Name'] ?></h4>
<h4 class="price">$<?= $get_product['0']['Price'] ?></h4>
<div class="short_overview">
<p><?= $get_product['0']['Short_Description'] ?></p>
</div>
<?php
$productSoldQtyByProductId=productSoldQtyByProductId($con,$get_product['0']['Id']);
$cart_show='yes';
if($get_product['0']['Qty']>$productSoldQtyByProductId){
$stock='In Stock';
}else{
$stock='Not in Stock';
$cart_show='';
}
?>
<div class="products--meta">
<p>
<span>Availability:</span>
<?php
if($cart_show!=''){
?>
<span class="mb-4"><?= $stock ?></span>
<?php
}else{
?>
<span style="color:red;" class="mb-4"><?= $stock ?></span>
<?php
}
?>
</p>
</div>
<?php
if($cart_show!=''){
?>
<div class="cart--area d-flex flex-wrap align-items-center">
<!-- Add to Cart Form -->
<form class="cart clearfix d-flex align-items-center" method="post">
<div class="quantity">
<span class="qty-minus"
onclick="var effect = document.getElementById('qty'); var qty = effect.value; if( !isNaN( qty ) && qty > 1 ) effect.value--;return false;"><i
class="fa fa-minus" aria-hidden="true"></i></span>
<input type="number" class="qty-text" id="qty" step="1" min="1" max="12"
name="quantity" value="1">
<span class="qty-plus"
onclick="var effect = document.getElementById('qty'); var qty = effect.value; if( !isNaN( qty )) effect.value++;return false;"><i
class="fa fa-plus" aria-hidden="true"></i></span>
</div>
<a class="btn alazea-btn ml-15" href="javascript:void(0)" onclick="manage_cart('<?= $get_product['0']['Id']?>','add'); "><i class="fa fa-shopping-cart mr-1"></i> Add To Cart</a>
</form>
<!-- Wishlist -->
<div class="wishlist-compare d-flex flex-wrap align-items-center">
<button style="border:none; color:#70c745" class="wishlist-btn ml-15" id="favorite-button">
<i class="fa <?= $is_favorited ? 'fa-heart' : 'fa-heart-o' ?>"></i>
</button>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const favoriteButton = document.getElementById('favorite-button');
<?php if (isset($_SESSION['USER_LOGIN'])) { ?>
favoriteButton.addEventListener('click', function() {
// Send AJAX request to update favorite status
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
// Parse the response to get favorited status
const response = JSON.parse(xhr.responseText);
const isFavorited = response.is_favorited;
// Toggle the heart icon
favoriteButton.querySelector('i').classList.toggle('fa-heart', isFavorited);
favoriteButton.querySelector('i').classList.toggle('fa-heart-o', !isFavorited);
}
};
xhr.open('POST', 'update_favorite.php', true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.send('user_id=<?= $user_id ?>&product_id=<?= $product_id ?>');
});
<?php } ?>
});
</script>
<?php
}
?>
<div class="products--meta">
<p><span>Category:</span> <span><?= $get_product['0']['Categories'] ?></span></p>
<p>
<span>Share on:</span>
<span>
<a href="#"><i class="fa fa-facebook"></i></a>
<a href="#"><i class="fa fa-twitter"></i></a>
<a href="#"><i class="fa fa-pinterest"></i></a>
<a href="#"><i class="fa fa-google-plus"></i></a>
</span>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-12">
<div class="product_details_tab clearfix">
<!-- Tabs -->
<ul class="nav nav-tabs" role="tablist" id="product-details-tab">
<li class="nav-item">
<a href="#description" class="nav-link active" data-toggle="tab" role="tab">Description</a>
</li>
<!-- <li class="nav-item">
<a href="#reviews" class="nav-link" data-toggle="tab" role="tab">Reviews <span
class="text-muted">(1)</span></a>
</li> -->
</ul>
<!-- Tab Content -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade show active" id="description">
<div class="description_area">
<?php
echo $get_product['0']['Description'];
?>
</div>
</div>
<div role="tabpanel" class="tab-pane fade" id="reviews">
<div class="reviews_area">
<ul>
<li>
<div class="single_user_review mb-15">
<div class="review-rating">
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<span>for Quality</span>
</div>
<div class="review-details">
<p>by <a href="#">Colorlib</a> on <span>12 Sep 2018</span></p>
</div>
</div>
<div class="single_user_review mb-15">
<div class="review-rating">
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<span>for Design</span>
</div>
<div class="review-details">
<p>by <a href="#">Colorlib</a> on <span>12 Sep 2018</span></p>
</div>
</div>
<div class="single_user_review">
<div class="review-rating">
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<i class="fa fa-star" aria-hidden="true"></i>
<span>for Value</span>
</div>
<div class="review-details">
<p>by <a href="#">Colorlib</a> on <span>12 Sep 2018</span></p>
</div>
</div>
</li>
</ul>
</div>
<!-- <div class="submit_a_review_area mt-50">
<h4>Submit A Review</h4>
<form action="#" method="post">
<div class="row">
<div class="col-12">
<div class="form-group d-flex align-items-center">
<span class="mr-15">Your Ratings:</span>
<div class="stars">
<input type="radio" name="star" class="star-1" id="star-1">
<label class="star-1" for="star-1">1</label>
<input type="radio" name="star" class="star-2" id="star-2">
<label class="star-2" for="star-2">2</label>
<input type="radio" name="star" class="star-3" id="star-3">
<label class="star-3" for="star-3">3</label>
<input type="radio" name="star" class="star-4" id="star-4">
<label class="star-4" for="star-4">4</label>
<input type="radio" name="star" class="star-5" id="star-5">
<label class="star-5" for="star-5">5</label>
<span></span>
</div>
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<label for="name">Nickname</label>
<input type="email" class="form-control" id="name" placeholder="Nazrul">
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<label for="options">Reason for your rating</label>
<select class="form-control" id="options">
<option>Quality</option>
<option>Value</option>
<option>Design</option>
<option>Price</option>
<option>Others</option>
</select>
</div>
</div>
<div class="col-12">
<div class="form-group">
<label for="comments">Comments</label>
<textarea class="form-control" id="comments" rows="5"
data-max-length="150"></textarea>
</div>
</div>
<div class="col-12">
<button type="submit" class="btn alazea-btn">Submit Your Review</button>
</div>
</div>
</form>
</div> -->
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- ##### Single Product Details Area End ##### -->
<?php
$relatedProducts = get_product($con, 4, $get_product['0']['Category_Id']);
?>
<!-- ##### Related Product Area Start ##### -->
<div class="related-products-area <?php if (count($relatedProducts) <= 0) echo 'd-none'; ?>">
<div class="container">
<div class="row">
<div class="col-12">
<!-- Section Heading -->
<div class="section-heading text-center">
<h2>Related Products</h2>
</div>
</div>
</div>
<div class="row">
<?php foreach($relatedProducts as $product) { ?>
<!-- Single Product Area -->
<div class="col-12 col-sm-6 col-lg-3">
<div class="single-product-area mb-100">
<!-- Product Image -->
<div class="product-img">
<a href="product.php"><img src="/image/<?= $product['Image'] ?>" alt=""></a>
<!-- Product Tag -->
<div class="product-tag">
<a href="#">Hot</a>
</div>
<div class="product-meta d-flex justify-content-center">
<a href="cart.php" class="add-to-cart-btn">Add to cart</a>
<!-- <a href="#" class="wishlist-btn"><i class="icon_heart_alt"></i></a>
<a href="#" class="compare-btn"><i class="arrow_left-right_alt"></i></a> -->
</div>
</div>
<!-- Product Info -->
<div class="product-info mt-15 text-center">
<a href="product.php?id=<?= $product['Id'] ?>">
<p><?= $product['Name'] ?></p>
</a>
<h6>$<?= $product['Price'] ?></h6>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<!-- ##### Related Product Area End ##### -->
<?php
include 'footer.php';
?>