-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart_body.php
666 lines (362 loc) · 27.1 KB
/
cart_body.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
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
<?php
session_start();
$active='Cart';
include("includes/db.php");
include("functions/functions.php");
?>
<body>
<div id="top"><!-- Top Begin -->
<div class="container"><!-- container Begin -->
<div class="col-md-6 offer"><!-- col-md-6 offer Begin -->
<a href="#" class="btn btn-success btn-sm">
<?php
if(!isset($_SESSION['customer_email'])){
echo "Welcome: Guest";
}else{
echo "Welcome: " . $_SESSION['customer_email'] . "";
}
?>
</a>
<a href="checkout.php"><?php items(); ?> Items In Your Cart | Total Price: <?php total_price(); ?> </a>
</div><!-- col-md-6 offer Finish -->
<div class="col-md-6"><!-- col-md-6 Begin -->
<ul class="menu"><!-- cmenu Begin -->
<li>
<a href="customer_register.php">Register</a>
</li>
<li>
<a href="checkout.php">My Account</a>
</li>
<li>
<a href="cart.php">Go To Cart</a>
</li>
<li>
<a href="checkout.php">
<?php
if(!isset($_SESSION['customer_email'])){
echo "<a href='checkout.php'> Login </a>";
}else{
echo " <a href='logout.php'> Log Out </a> ";
}
?>
</a>
</li>
</ul><!-- menu Finish -->
</div><!-- col-md-6 Finish -->
</div><!-- container Finish -->
</div><!-- Top Finish -->
<div id="navbar" class="navbar navbar-default"><!-- navbar navbar-default Begin -->
<div class="container"><!-- container Begin -->
<div class="navbar-header"><!-- navbar-header Begin -->
<a href="index.php" class="navbar-brand home"><!-- navbar-brand home Begin -->
<img src="images/ecom-store-logo.png" alt="M-dev-Store Logo" class="hidden-xs">
<img src="images/ecom-store-logo-mobile.png" alt="M-dev-Store Logo Mobile" class="visible-xs">
</a><!-- navbar-brand home Finish -->
<button class="navbar-toggle" data-toggle="collapse" data-target="#navigation">
<span class="sr-only">Toggle Navigation</span>
<i class="fa fa-align-justify"></i>
</button>
<button class="navbar-toggle" data-toggle="collapse" data-target="#search">
<span class="sr-only">Toggle Search</span>
<i class="fa fa-search"></i>
</button>
</div><!-- navbar-header Finish -->
<div class="navbar-collapse collapse" id="navigation"><!-- navbar-collapse collapse Begin -->
<div class="padding-nav"><!-- padding-nav Begin -->
<ul class="nav navbar-nav left"><!-- nav navbar-nav left Begin -->
<li class="<?php if($active=='Home') echo"active"; ?>">
<a href="index.php">Home</a>
</li>
<li class="<?php if($active=='Shop') echo"active"; ?>">
<a href="shop.php">Shop</a>
</li>
<li class="<?php if($active=='Account') echo"active"; ?>">
<?php
if(!isset($_SESSION['customer_email'])){
echo"<a href='checkout.php'>My Account</a>";
}else{
echo"<a href='customer/my_account.php?my_orders'>My Account</a>";
}
?>
</li>
<li class="<?php if($active=='Cart') echo"active"; ?>">
<a href="cart.php">Shopping Cart</a>
</li>
<li class="<?php if($active=='Contact') echo"active"; ?>">
<a href="contact.php">Contact Us</a>
</li>
</ul><!-- nav navbar-nav left Finish -->
</div><!-- padding-nav Finish -->
<a href="cart.php" class="btn navbar-btn btn-primary right"><!-- btn navbar-btn btn-primary Begin -->
<i class="fa fa-shopping-cart"></i>
<span><?php items(); ?> Items In Your Cart</span>
</a><!-- btn navbar-btn btn-primary Finish -->
<div class="navbar-collapse collapse right"><!-- navbar-collapse collapse right Begin -->
<button class="btn btn-primary navbar-btn" type="button" data-toggle="collapse" data-target="#search"><!-- btn btn-primary navbar-btn Begin -->
<span class="sr-only">Toggle Search</span>
<i class="fa fa-search"></i>
</button><!-- btn btn-primary navbar-btn Finish -->
</div><!-- navbar-collapse collapse right Finish -->
<div class="collapse clearfix" id="search"><!-- collapse clearfix Begin -->
<form method="get" action="results.php" class="navbar-form"><!-- navbar-form Begin -->
<div class="input-group"><!-- input-group Begin -->
<input type="text" class="form-control" placeholder="Search" name="user_query" required>
<span class="input-group-btn"><!-- input-group-btn Begin -->
<button type="submit" name="search" value="Search" class="btn btn-primary"><!-- btn btn-primary Begin -->
<i class="fa fa-search"></i>
</button><!-- btn btn-primary Finish -->
</span><!-- input-group-btn Finish -->
</div><!-- input-group Finish -->
</form><!-- navbar-form Finish -->
</div><!-- collapse clearfix Finish -->
</div><!-- navbar-collapse collapse Finish -->
</div><!-- container Finish -->
</div><!-- navbar navbar-default Finish -->
<div id="content"><!-- #content Begin -->
<div class="container"><!-- container Begin -->
<div class="col-md-12"><!-- col-md-12 Begin -->
<ul class="breadcrumb"><!-- breadcrumb Begin -->
<li>
<a href="index.php">Home</a>
</li>
<li>
Cart
</li>
</ul><!-- breadcrumb Finish -->
</div><!-- col-md-12 Finish -->
<div id="cart" class="col-md-9"><!-- col-md-9 Begin -->
<div class="box"><!-- box Begin -->
<form action="cart.php" method="post" enctype="multipart/form-data"><!-- form Begin -->
<h1>Shopping Cart</h1>
<?php
$ip_add = getRealIpUser();
$select_cart = "select * from cart where ip_add='$ip_add'";
$run_cart = mysqli_query($con,$select_cart);
$count = mysqli_num_rows($run_cart);
?>
<p class="text-muted">You currently have <?php echo $count; ?> item(s) in your cart</p>
<div class="table-responsive"><!-- table-responsive Begin -->
<table class="table"><!-- table Begin -->
<thead><!-- thead Begin -->
<tr><!-- tr Begin -->
<th colspan="2">Product</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Size</th>
<th colspan="1">Delete</th>
<th colspan="2">Sub-Total</th>
</tr><!-- tr Finish -->
</thead><!-- thead Finish -->
<tbody><!-- tbody Begin -->
<?php
$total = 0;
while($row_cart = mysqli_fetch_array($run_cart)){
$pro_id = $row_cart['p_id'];
$pro_size = $row_cart['size'];
$pro_qty = $row_cart['qty'];
$pro_sale = $row_cart['p_price'];
$get_products = "select * from products where product_id='$pro_id'";
$run_products = mysqli_query($con,$get_products);
while($row_products = mysqli_fetch_array($run_products)){
$product_title = $row_products['product_title'];
$product_img1 = $row_products['product_img1'];
$only_price = $row_products['product_price'];
$sub_total = $pro_sale*$pro_qty;
$_SESSION['pro_qty'] = $pro_qty;
$total += $sub_total;
?>
<tr><!-- tr Begin -->
<td>
<img class="img-responsive" src="admin_area/product_images/<?php echo $product_img1; ?>" alt="Product 3a">
</td>
<td>
<a href="details.php?pro_id=<?php echo $pro_id; ?>"> <?php echo $product_title; ?> </a>
</td>
<td>
<input type="text" name="quantity" data-product_id="<?php echo $pro_id; ?>" value="<?php echo $_SESSION['pro_qty']; ?>" class="quantity form-control">
</td>
<td>
<?php echo $pro_sale; ?>
</td>
<td>
<?php echo $pro_size; ?>
</td>
<td>
<input type="checkbox" name="remove[]" value="<?php echo $pro_id; ?>">
</td>
<td>
$<?php echo $sub_total; ?>
</td>
</tr><!-- tr Finish -->
<?php } } ?>
</tbody><!-- tbody Finish -->
<tfoot><!-- tfoot Begin -->
<tr><!-- tr Begin -->
<th colspan="5">Total</th>
<th colspan="2">$<?php echo $total; ?></th>
</tr><!-- tr Finish -->
</tfoot><!-- tfoot Finish -->
</table><!-- table Finish -->
</div><!-- table-responsive Finish -->
<div class="box-footer"><!-- box-footer Begin -->
<div class="pull-left"><!-- pull-left Begin -->
<a href="index.php" class="btn btn-default"><!-- btn btn-default Begin -->
<i class="fa fa-chevron-left"></i> Continue Shopping
</a><!-- btn btn-default Finish -->
</div><!-- pull-left Finish -->
<div class="pull-right"><!-- pull-right Begin -->
<button type="submit" name="update" value="Update Cart" class="btn btn-default"><!-- btn btn-default Begin -->
<i class="fa fa-refresh"></i> Update Cart
</button><!-- btn btn-default Finish -->
<a href="checkout.php" class="btn btn-primary">
Proceed Checkout <i class="fa fa-chevron-right"></i>
</a>
</div><!-- pull-right Finish -->
</div><!-- box-footer Finish -->
</form><!-- form Finish -->
</div><!-- box Finish -->
<?php
function update_cart(){
global $con;
if(isset($_POST['update'])){
foreach($_POST['remove'] as $remove_id){
$delete_product = "delete from cart where p_id='$remove_id'";
$run_delete = mysqli_query($con,$delete_product);
if($run_delete){
echo "<script>window.open('cart.php','_self')</script>";
}
}
}
}
echo @$up_cart = update_cart();
?>
<div id="row same-heigh-row"><!-- #row same-heigh-row Begin -->
<div class="col-md-3 col-sm-6"><!-- col-md-3 col-sm-6 Begin -->
<div class="box same-height headline"><!-- box same-height headline Begin -->
<h3 class="text-center">Products You Maybe Like</h3>
</div><!-- box same-height headline Finish -->
</div><!-- col-md-3 col-sm-6 Finish -->
<?php
$get_products = "select * from products order by rand() LIMIT 0,3";
$run_products = mysqli_query($con,$get_products);
while($row_products=mysqli_fetch_array($run_products)){
$pro_id = $row_products['product_id'];
$pro_title = $row_products['product_title'];
$pro_price = $row_products['product_price'];
$pro_sale_price = $row_products['product_sale'];
$pro_img1 = $row_products['product_img1'];
$pro_label = $row_products['product_label'];
$manufacturer_id = $row_products['manufacturer_id'];
$get_manufacturer = "select * from manufacturers where manufacturer_id='$manufacturer_id'";
$run_manufacturer = mysqli_query($db,$get_manufacturer);
$row_manufacturer = mysqli_fetch_array($run_manufacturer);
$manufacturer_title = $row_manufacturer['manufacturer_title'];
if($pro_label == "sale"){
$product_price = " <del> $ $pro_price </del> ";
$product_sale_price = "/ $ $pro_sale_price ";
}else{
$product_price = " $ $pro_price ";
$product_sale_price = "";
}
if($pro_label == ""){
}else{
$product_label = "
<a href='#' class='label $pro_label'>
<div class='theLabel'> $pro_label </div>
<div class='labelBackground'> </div>
</a>
";
}
echo "
<div class='col-md-3 col-sm-6 center-responsive'>
<div class='product'>
<a href='details.php?pro_id=$pro_id'>
<img class='img-responsive' src='admin_area/product_images/$pro_img1'>
</a>
<div class='text'>
<center>
<p class='btn btn-primary'> $manufacturer_title </p>
</center>
<h3>
<a href='details.php?pro_id=$pro_id'>
$pro_title
</a>
</h3>
<p class='price'>
$product_price $product_sale_price
</p>
<p class='button'>
<a class='btn btn-default' href='details.php?pro_id=$pro_id'>
View Details
</a>
<a class='btn btn-primary' href='details.php?pro_id=$pro_id'>
<i class='fa fa-shopping-cart'></i> Add to Cart
</a>
</p>
</div>
$product_label
</div>
</div>
";
}
?>
</div><!-- #row same-heigh-row Finish -->
</div><!-- col-md-9 Finish -->
<div class="col-md-3"><!-- col-md-3 Begin -->
<div id="order-summary" class="box"><!-- box Begin -->
<div class="box-header"><!-- box-header Begin -->
<h3>Order Summary</h3>
</div><!-- box-header Finish -->
<p class="text-muted"><!-- text-muted Begin -->
Shipping and additional costs are calculated based on value you have entered
</p><!-- text-muted Finish -->
<div class="table-responsive"><!-- table-responsive Begin -->
<table class="table"><!-- table Begin -->
<tbody><!-- tbody Begin -->
<tr><!-- tr Begin -->
<td> Order All Sub-Total </td>
<th> $<?php echo $total; ?> </th>
</tr><!-- tr Finish -->
<tr><!-- tr Begin -->
<td> Shipping and Handling </td>
<td> $0 </td>
</tr><!-- tr Finish -->
<tr><!-- tr Begin -->
<td> Tax </td>
<th> $0 </th>
</tr><!-- tr Finish -->
<tr class="total"><!-- tr Begin -->
<td> Total </td>
<th> $<?php echo $total; ?> </th>
</tr><!-- tr Finish -->
</tbody><!-- tbody Finish -->
</table><!-- table Finish -->
</div><!-- table-responsive Finish -->
</div><!-- box Finish -->
</div><!-- col-md-3 Finish -->
</div><!-- container Finish -->
</div><!-- #content Finish -->
<?php
include("includes/footer.php");
?>
<script src="js/jquery-331.min.js"></script>
<script src="js/bootstrap-337.min.js"></script>
<script>
$(document).ready(function(data){
$(document).on('keyup','.quantity',function(){
var id = $ (this).data("product_id");
var quantity = $(this).val();
if(quantity !=''){
$.ajax({
url: "change.php",
method: "POST",
data:{id:id, quantity:quantity},
success:function(){
$("body").load("cart_body.php");
}
});
}
});
});
</script>
</body>