-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.php
428 lines (380 loc) · 17.2 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
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
<?php
ob_start();
require('top.php');
if(isset($_GET['id'])){
$product_id=mysqli_real_escape_string($con,$_GET['id']);
if($product_id>0){
$get_product=get_product($con,'','',$product_id);
}else{
?>
<script>
window.location.href='index.php';
</script>
<?php
}
$resMultipleImages=mysqli_query($con,"select product_images from product_images where product_id='$product_id'");
$multipleImages=[];
if(mysqli_num_rows($resMultipleImages)>0){
while($rowMultipleImages=mysqli_fetch_assoc($resMultipleImages)){
$multipleImages[]=$rowMultipleImages['product_images'];
}
}
$resAttr=mysqli_query($con,"select product_attributes.*,color_master.color,rom_master.size from product_attributes
left join color_master on product_attributes.color_id=color_master.id and color_master.status=1
left join rom_master on product_attributes.size_id=rom_master.id and rom_master.status=1
where product_attributes.product_id='$product_id'");
$productAttr=[];
$colorArr=[];
$sizeArr=[];
if(mysqli_num_rows($resAttr)>0){
while($rowAttr=mysqli_fetch_assoc($resAttr)){
$productAttr[]=$rowAttr;
$colorArr[$rowAttr['color_id']][]=$rowAttr['color'];
$sizeArr[$rowAttr['size_id']][]=$rowAttr['size'];
$colorArr1[]=$rowAttr['color'];
$sizeArr1[]=$rowAttr['size'];
}
}
$is_size=count(array_filter($sizeArr1));
$is_color=count(array_filter($colorArr1));
//$colorArr=array_unique($colorArr);
//$sizeArr=array_unique($sizeArr1);
}else{
?>
<script>
window.location.href='index.php';
</script>
<?php
}
if(isset($_POST['review_submit'])){
$rating=get_safe_value($con,$_POST['rating']);
$review=get_safe_value($con,$_POST['review']);
$added_on=date('Y-m-d h:i:s');
mysqli_query($con,"insert into product_review(product_id,user_id,rating,review,status,added_on) values('$product_id','".$_SESSION['USER_ID']."','$rating','$review','1','$added_on')");
// header('location:product.php?id='.$product_id);
echo "<script>window.location.href='product.php?id='.$product_id;</script>";
// die();
}
$product_review_res=mysqli_query($con,"select users.name,product_review.id,product_review.rating,product_review.review,product_review.added_on from users,product_review where product_review.status=1 and product_review.user_id=users.id and product_review.product_id='$product_id' order by product_review.added_on desc");
?>
<!-- Start Bradcaump area -->
<div class="ht__bradcaump__area" style="background: rgba(0, 0, 0, 0) url(images/bg/4.jpg) no-repeat scroll center center / cover ;">
<div class="ht__bradcaump__wrap">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="bradcaump__inner">
<nav class="bradcaump-inner">
<a class="breadcrumb-item" href="index.php">Home</a>
<span class="brd-separetor"><i class="zmdi zmdi-chevron-right"></i></span>
<a class="breadcrumb-item" href="categories.php?id=<?php echo $get_product['0']['categories_id']?>"><?php echo $get_product['0']['categories']?></a>
<span class="brd-separetor"><i class="zmdi zmdi-chevron-right"></i></span>
<span class="breadcrumb-item active"><?php echo $get_product['0']['name']?></span>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End Bradcaump area -->
<!-- Start Product Details Area -->
<section class="htc__product__details bg__white ptb--100">
<!-- Start Product Details Top -->
<div class="htc__product__details__top">
<div class="container">
<div class="row">
<div class="col-md-5 col-lg-5 col-sm-12 col-xs-12">
<div class="htc__product__details__tab__content">
<!-- Start Product Big Images -->
<div class="product__big__images">
<div class="portfolio-full-image tab-content">
<div role="tabpanel" class="tab-pane fade in active imageZoom" id="img-tab-1">
<img width="" data-origin="<?php echo PRODUCT_IMAGE_SITE_PATH.$get_product['0']['image']?>" src="<?php echo PRODUCT_IMAGE_SITE_PATH.$get_product['0']['image']?>">
</div>
<?php if(isset($multipleImages[0])){?>
<div id="multiple_images">
<?php
foreach($multipleImages as $list){
echo "<img src='".PRODUCT_MULTIPLE_IMAGE_SITE_PATH.$list."' onclick=showMultipleImage('".PRODUCT_MULTIPLE_IMAGE_SITE_PATH.$list."')>";
}
?>
</div>
<?php } ?>
</div>
</div>
<!-- End Product Big Images -->
</div>
</div>
<div class="col-md-7 col-lg-7 col-sm-12 col-xs-12 smt-40 xmt-40">
<div class="ht__product__dtl">
<h2><?php echo $get_product['0']['name']?></h2>
<ul class="pro__prize">
<li class="old__prize"><?php echo $get_product['0']['mrp']?></li>
<li class="new__price"><?php echo $get_product['0']['price']?></li>
</ul>
<p class="pro__info"><?php echo $get_product['0']['short_desc']?></p>
<div class="ht__pro__desc">
<?php
$cart_show='yes';
$is_cart_box_show="hide";
if($is_color==0 && $is_size==0){
$is_cart_box_show="";
?>
<div class="sin__desc">
<?php
$getProductAttr=getProductAttr($con,$get_product['0']['id']);
$productSoldQtyByProductId=productSoldQtyByProductId($con,$get_product['0']['id'],$getProductAttr);
$pending_qty=$get_product['0']['qty']-$productSoldQtyByProductId;
$cart_show='yes';
if($get_product['0']['qty']>$productSoldQtyByProductId){
$stock='In Stock';
}else{
$stock='Not in Stock';
$cart_show='';
}
?>
<p><span>Availability:</span> <?php echo $stock?></p>
</div>
<?php } ?>
<?php if($is_color>0){?>
<div class="sin__desc align--left">
<p><span>color:</span></p>
<ul class="pro__color">
<?php
foreach($colorArr as $key=>$val){
echo "<li style='background:".$val[0]." none repeat scroll 0 0'><a href='javascript:void(0)' onclick=loadAttr('".$key."','".$get_product['0']['id']."','color')>".$val[0]."</a></li>";
}
?>
</ul>
</div>
<?php } ?>
<?php if($is_size>0){?>
<div class="sin__desc align--left">
<p><span>rom</span></p>
<select class="select__size" id="size_attr" onchange="showQty()">
<option value="">Size</option>
<?php
foreach($sizeArr as $key=>$val){
echo "<option value='".$key."'>".$val[0]."</option>";
}
?>
</select>
</div>
<?php } ?>
<?php
$isQtyHide="hide";
if($is_color==0 && $is_size==0){
$isQtyHide="";
}
?>
<div class="sin__desc align--left <?php echo $isQtyHide?>" id="cart_qty">
<?php
if($cart_show!=''){
?>
<p><span>Qty:</span>
<select id="qty" class="select__size">
<?php
for($i=1;$i<=$pending_qty;$i++){
echo "<option>$i</option>";
}
?>
</select>
</p>
<?php } ?>
</div>
<div id="cart_attr_msg"></div>
<div class="sin__desc align--left">
<p><span>Categories:</span></p>
<ul class="pro__cat__list">
<li><a href="#"><?php echo $get_product['0']['categories']?></a></li>
</ul>
</div>
</div>
</div>
<div id="is_cart_box_show" class="<?php echo $is_cart_box_show?>">
<a class="fr__btn" href="javascript:void(0)" onclick="manage_cart('<?php echo $get_product['0']['id']?>','add')">Add to cart</a>
<a class="fr__btn buy_now" href="checkout.php" onclick="manage_cart('<?php echo $get_product['0']['id']?>','add')">Buy Now</a>
<!-- <a class="fr__btn buy_now" href="javascript:void(0)" onclick="manage_cart('<?php echo $get_product['0']['id']?>','add','yes')">Buy Now</a> -->
</div>
<div id="social_share_box">
<a href="https://facebook.com/share.php?u=<?php echo $meta_url?>"><img src='images/icons/facebook.png'/></a>
<a href="https://twitter.com/share?text=<?php echo $get_product['0']['name']?>&url=<?php echo $meta_url?>"><img src='images/icons/twitter.png'/></a>
<a href="https://api.whatsapp.com/send?text=<?php echo $get_product['0']['name']?> <?php echo $meta_url?>"><img src='images/icons/whatsapp.png'/></a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End Product Details Top -->
</section>
<input type="hidden" id="cid"/>
<input type="hidden" id="sid"/>
<!-- End Product Details Area
<!-- Start Product Description -->
<section class="htc__produc__decription bg__white">
<div class="container">
<div class="row">
<div class="col-xs-12">
<!-- Start List And Grid View -->
<ul class="pro__details__tab" role="tablist">
<li role="presentation" class="description active"><a href="#description" role="tab" data-toggle="tab">description</a></li>
<li role="presentation" class="review"><a href="#review" role="tab" data-toggle="tab" class="active show" aria-selected="true">review</a></li>
</ul>
<!-- End List And Grid View -->
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="ht__pro__details__content">
<!-- Start Single Content -->
<div role="tabpanel" id="description" class="pro__single__content tab-pane fade in active">
<div class="pro__tab__content__inner">
<?php echo $get_product['0']['description']?>
</div>
</div>
<!-- End Single Content -->
<div role="tabpanel" id="review" class="pro__single__content tab-pane fade active show">
<div class="pro__tab__content__inner">
<?php
if(mysqli_num_rows($product_review_res)>0){
while($product_review_row=mysqli_fetch_assoc($product_review_res)){
?>
<article class="row">
<div class="col-md-12 col-sm-12">
<div class="panel panel-default arrow left">
<div class="panel-body">
<header class="text-left">
<div><span class="comment-rating"> <?php echo $product_review_row['rating']?></span> (<?php echo $product_review_row['name']?>)</div>
<time class="comment-date">
<?php
$added_on=strtotime($product_review_row['added_on']);
echo date('d M Y',$added_on);
?>
</time>
</header>
<div class="comment-post">
<p>
<?php echo $product_review_row['review']?>
</p>
</div>
</div>
</div>
</div>
</article>
<?php } }else {
echo "<h3 class='submit_review_hint'>No review added</h3><br/>";
}
?>
<h3 class="review_heading">Enter your review</h3><br/>
<?php
if(isset($_SESSION['USER_LOGIN'])){
?>
<div class="row" id="post-review-box" style=>
<div class="col-md-12">
<form action="" method="post">
<select class="form-control" name="rating" required>
<option value="">Select Rating</option>
<option>Worst</option>
<option>Bad</option>
<option>Good</option>
<option>Very Good</option>
<option>Fantastic</option>
</select> <br/>
<textarea class="form-control" cols="50" id="new-review" name="review" placeholder="Enter your review here..." rows="5"></textarea>
<div class="text-right mt10">
<button class="btn btn-success btn-lg" type="submit" name="review_submit">Submit</button>
</div>
</form>
</div>
</div>
<?php } else {
echo "<span class='submit_review_hint'>Please <a href='login.php'>login</a> to submit your review</span>";
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- End Product Description -->
<?php
//unset($_COOKIE['recently_viewed']);
if(isset($_COOKIE['recently_viewed'])){
$arrRecentView=unserialize($_COOKIE['recently_viewed']);
$countRecentView=count($arrRecentView);
$countStartRecentView=$countRecentView-4;
if($countStartRecentView>4){
$arrRecentView=array_slice($arrRecentView,$countStartRecentView,4);
}
$recentViewId=implode(",",$arrRecentView);
$res=mysqli_query($con,"select * from product where id IN ($recentViewId) and status=1");
?>
<section class="htc__produc__decription bg__white">
<div class="container">
<div class="row">
<div class="col-xs-12">
<h3 style="font-size: 20px;font-weight: bold;">Recently Viewed</h3>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="ht__pro__details__content">
<div class="row">
<?php while($list=mysqli_fetch_assoc($res)){?>
<div class="col-xs-3">
<div class="category">
<div class="ht__cat__thumb">
<a href="product.php?id=<?php echo $list['id']?>">
<img src="<?php echo PRODUCT_IMAGE_SITE_PATH.$list['image']?>" alt="product images">
</a>
</div>
<div class="fr__hover__info">
<ul class="product__action">
<li><a href="javascript:void(0)" onclick="wishlist_manage('<?php echo $list['id']?>','add')"><i class="icon-heart icons"></i></a></li>
<li><a href="javascript:void(0)" onclick="manage_cart('<?php echo $list['id']?>','add')"><i class="icon-handbag icons"></i></a></li>
</ul>
</div>
<div class="fr__product__inner">
<h4><a href="product.php?id=<?php echo $list['id']?>"><?php echo $list['name']?></a></h4>
<ul class="fr__pro__prize">
<li class="old__prize"><?php echo $list['mrp']?></li>
<li class="new__price"><?php echo $list['price']?></li>
</ul>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</section>
<?php
$arrRec=unserialize($_COOKIE['recently_viewed']);
if(($key=array_search($product_id,$arrRec))!==false){
unset($arrRec[$key]);
}
$arrRec[]=$product_id;
}else{
$arrRec[]=$product_id;
}
setcookie('recently_viewed',serialize($arrRec),time()+60*60*24*365);
?>
<script>
function showMultipleImage(im){
jQuery('#img-tab-1').html("<img src='"+im+"' data-origin='"+im+"'/>");
jQuery('.imageZoom').imgZoom();
}
let is_color='<?php echo $is_color?>';
let is_size='<?php echo $is_size?>';
let pid='<?php echo $product_id?>';
</script>
<?php
require('footer.php');
ob_flush();
?>