-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
executable file
·626 lines (321 loc) · 10.1 KB
/
cart.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
<?php
session_start();
include("includes/db.php");
include("functions/functions.php");
?>
<!DOCTYPE html>
<html>
<head>
<title>E commerce Store </title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="http://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100" rel="stylesheet" >
<link href="styles/bootstrap.min.css" rel="stylesheet">
<link href="styles/style.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<div id="top"><!-- top Starts -->
<div class="container"><!-- container Starts -->
<div class="col-md-6 offer"><!-- col-md-6 offer Starts -->
<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="#">
Shopping Cart Total Price: <?php total_price(); ?>, Total Items <?php items(); ?>
</a>
</div><!-- col-md-6 offer Ends -->
<div class="col-md-6"><!-- col-md-6 Starts -->
<ul class="menu"><!-- menu Starts -->
<li>
<a href="customer_register.php">
Register
</a>
</li>
<li>
<?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>
<a href="cart.php">
Go to Cart
</a>
</li>
<li>
<?php
if(!isset($_SESSION['customer_email'])){
echo "<a href='checkout.php'> Login </a>";
}else {
echo "<a href='logout.php'> Logout </a>";
}
?>
</li>
</ul><!-- menu Ends -->
</div><!-- col-md-6 Ends -->
</div><!-- container Ends -->
</div><!-- top Ends -->
<div class="navbar navbar-default" id="navbar"><!-- navbar navbar-default Starts -->
<div class="container" ><!-- container Starts -->
<div class="navbar-header"><!-- navbar-header Starts -->
<a class="navbar-brand home" href="index.php" ><!--- navbar navbar-brand home Starts -->
<img src="images/ecom-store-logo.png" alt="ecom logo" class="hidden-xs" >
<img src="images/ecom-store-logo-mobile.png" alt="ecom logo" class="visible-xs" >
</a><!--- navbar navbar-brand home Ends -->
<button type="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 type="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 Ends -->
<div class="navbar-collapse collapse" id="navigation" ><!-- navbar-collapse collapse Starts -->
<div class="padding-nav" ><!-- padding-nav Starts -->
<ul class="nav navbar-nav navbar-left"><!-- nav navbar-nav navbar-left Starts -->
<li>
<a href="index.php"> Home </a>
</li>
<li>
<a href="shop.php"> Shop </a>
</li>
<li>
<?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="active" >
<a href="cart.php"> Shopping Cart </a>
</li>
<li>
<a href="contact.php"> Contact Us </a>
</li>
</ul><!-- nav navbar-nav navbar-left Ends -->
</div><!-- padding-nav Ends -->
<a class="btn btn-primary navbar-btn right" href="cart.php"><!-- btn btn-primary navbar-btn right Starts -->
<i class="fa fa-shopping-cart"></i>
<span> <?php items(); ?> items in cart </span>
</a><!-- btn btn-primary navbar-btn right Ends -->
<div class="navbar-collapse collapse right"><!-- navbar-collapse collapse right Starts -->
<button class="btn navbar-btn btn-primary" type="button" data-toggle="collapse" data-target="#search">
<span class="sr-only">Toggle Search</span>
<i class="fa fa-search"></i>
</button>
</div><!-- navbar-collapse collapse right Ends -->
<div class="collapse clearfix" id="search"><!-- collapse clearfix Starts -->
<form class="navbar-form" method="get" action="results.php"><!-- navbar-form Starts -->
<div class="input-group"><!-- input-group Starts -->
<input class="form-control" type="text" placeholder="Search" name="user_query" required>
<span class="input-group-btn"><!-- input-group-btn Starts -->
<button type="submit" value="Search" name="search" class="btn btn-primary">
<i class="fa fa-search"></i>
</button>
</span><!-- input-group-btn Ends -->
</div><!-- input-group Ends -->
</form><!-- navbar-form Ends -->
</div><!-- collapse clearfix Ends -->
</div><!-- navbar-collapse collapse Ends -->
</div><!-- container Ends -->
</div><!-- navbar navbar-default Ends -->
<div id="content" ><!-- content Starts -->
<div class="container" ><!-- container Starts -->
<div class="col-md-12" ><!--- col-md-12 Starts -->
<ul class="breadcrumb" ><!-- breadcrumb Starts -->
<li>
<a href="index.php">Home</a>
</li>
<li>Cart</li>
</ul><!-- breadcrumb Ends -->
</div><!--- col-md-12 Ends -->
<div class="col-md-9" id="cart" ><!-- col-md-9 Starts -->
<div class="box" ><!-- box Starts -->
<form action="cart.php" method="post" enctype="multipart-form-data" ><!-- form Starts -->
<h1> Shopping Cart </h1>
<?php
$ip_add = getRealUserIp();
$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 Starts -->
<table class="table" ><!-- table Starts -->
<thead><!-- thead Starts -->
<tr>
<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>
</thead><!-- thead Ends -->
<tbody><!-- tbody Starts -->
<?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'];
$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 = $row_products['product_price']*$pro_qty;
$total += $sub_total;
?>
<tr><!-- tr Starts -->
<td>
<img src="admin_area/product_images/<?php echo $product_img1; ?>" >
</td>
<td>
<a href="#" > <?php echo $product_title; ?> </a>
</td>
<td>
<?php echo $pro_qty; ?>
</td>
<td>
BDT<?php echo $only_price; ?>.00
</td>
<td>
<?php echo $pro_size; ?>
</td>
<td>
<input type="checkbox" name="remove[]" value="<?php echo $pro_id; ?>" >
</td>
<td>
BDT<?php echo $sub_total; ?>.00
</td>
</tr><!-- tr Ends -->
<?php } } ?>
</tbody><!-- tbody Ends -->
<tfoot><!-- tfoot Starts -->
<tr>
<th colspan="5"> Total </th>
<th colspan="2"> BDT<?php echo $total; ?>.00 </th>
</tr>
</tfoot><!-- tfoot Ends -->
</table><!-- table Ends -->
</div><!-- table-responsive Ends -->
<div class="box-footer"><!-- box-footer Starts -->
<div class="pull-left"><!-- pull-left Starts -->
<a href="index.php" class="btn btn-default">
<i class="fa fa-chevron-left"></i> Continue Shopping
</a>
</div><!-- pull-left Ends -->
<div class="pull-right"><!-- pull-right Starts -->
<button class="btn btn-default" type="submit" name="update" value="Update Cart">
<i class="fa fa-refresh"></i> Update Cart
</button>
<a href="checkout.php" class="btn btn-primary">
Proceed to checkout <i class="fa fa-chevron-right"></i>
</a>
</div><!-- pull-right Ends -->
</div><!-- box-footer Ends -->
</form><!-- form Ends -->
</div><!-- box Ends -->
<?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-height-row"><!-- row same-height-row Starts -->
<div class="col-md-3 col-sm-6"><!-- col-md-3 col-sm-6 Starts -->
<div class="box same-height headline"><!-- box same-height headline Starts -->
<h3 class="text-center"> You also like these Products </h3>
</div><!-- box same-height headline Ends -->
</div><!-- col-md-3 col-sm-6 Ends -->
<?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_img1 = $row_products['product_img1'];
echo "
<div class='center-responsive col-md-3 col-sm-6 ' >
<div class='product same-height' >
<a href='details.php?pro_id=$pro_id' >
<img src='admin_area/product_images/$pro_img1' class='img-responsive' >
</a>
<div class='text' >
<h3><a href='details.php?pro_id=$pro_id' >$pro_title</a></h3>
<p class='price' >BDT $pro_price</p>
</div>
</div>
</div>
";
}
?>
</div><!-- row same-height-row Ends -->
</div><!-- col-md-9 Ends -->
<div class="col-md-3"><!-- col-md-3 Starts -->
<div class="box" id="order-summary"><!-- box Starts -->
<div class="box-header"><!-- box-header Starts -->
<h3>Order Summary</h3>
</div><!-- box-header Ends -->
<p class="text-muted">
Shipping and additional costs are calculated based on the values you have entered.
</p>
<div class="table-responsive"><!-- table-responsive Starts -->
<table class="table"><!-- table Starts -->
<tbody><!-- tbody Starts -->
<tr>
<td> Order Subtotal </td>
<th> BDT <?php echo $total; ?>.00 </th>
</tr>
<tr>
<td> Shipping and handling </td>
<th>BD T0.00</th>
</tr>
<tr>
<td>Tax</td>
<th>BDT 0.00</th>
</tr>
<tr class="total">
<td>Total</td>
<th>BDT<?php echo $total; ?>.00</th>
</tr>
</tbody><!-- tbody Ends -->
</table><!-- table Ends -->
</div><!-- table-responsive Ends -->
</div><!-- box Ends -->
</div><!-- col-md-3 Ends -->
</div><!-- container Ends -->
</div><!-- content Ends -->
<?php
include("includes/footer.php");
?>
<script src="js/jquery.min.js"> </script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>