-
Notifications
You must be signed in to change notification settings - Fork 1
/
cart.php
127 lines (108 loc) · 3.04 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
<?php include 'inc/header.php'; ?>
<?php
if (isset($_GET['delPro'])) {
$id = preg_replace('/[^-a-zA-Z0-9_]/', '', $_GET['delPro']);
$delProduct = $ct->deleteCartProductById($id);
}
?>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$cartId = $_POST['cartId'];
$quantity = $_POST['quantity'];
$updCart = $ct->updateCartById($quantity, $cartId);
}
?>
<?php
if (!isset($_GET['id'])) {
echo "<meta http-equiv='refresh' content='0;url=?id=live'/>";
}
?>
<div class="main">
<div class="content">
<div class="cartoption">
<div class="cartpage">
<h2>Your Cart</h2>
<?php
if (isset($updCart)) {
echo $updCart;
}
if(isset($delProduct)){
echo $delProduct;
}
?>
<table class="tblone">
<tr>
<th width="5%">SL</th>
<th width="30%">Product Name</th>
<th width="10%">Image</th>
<th width="15%">Price</th>
<th width="25%">Quantity</th>
<th width="15%">Total Price</th>
<th width="10%">Action</th>
</tr>
<?php
$getPro = $ct->getCartProduct();
$i = 0;
$sum = 0;
if ($getPro) {
while ($result = $getPro->fetch_assoc()) {
$i++;
?>
<tr>
<td> <?php echo $i; ?> </td>
<td> <?php echo $result['productName']; ?> </td>
<td><img src="admin/<?php echo $result['image']; ?>" alt=""/></td>
<td> $ <?php echo $result['price']; ?> </td>
<td>
<form action="" method="post">
<input type="hidden" name="cartId" value="<?php echo $result['cartId'];?>" min="1"/>
<input type="number" name="quantity" value="<?php echo $result['quantity'];?>" min="1"/>
<input type="submit" name="submit" value="Update"/>
</form>
</td>
<td> $
<?php
$total = $result['price'] * $result['quantity'];
$sum +=$total;
echo $total;
?>
</td>
<td><a onclick="return confirm('Are you sure for delete this product')" href="?delPro=<?php echo $result['cartId'];?>">X</a></td>
</tr>
<?php }
} else{
header("Location:index.php");
}
?>
</table>
<table style="float:right;text-align:left;" width="40%">
<tr>
<th>Sub Total : </th>
<td> $ <?php
echo $sum;
Session::set("sum",$sum);
?> </td>
</tr>
<tr>
<th>VAT : </th>
<td>$ <?php $vat = $sum/10; echo $vat; ?></td>
</tr>
<tr>
<th>Grand Total :</th>
<td> $ <?php echo ($vat+$sum); ?> </td>
</tr>
</table>
</div>
<div class="shopping">
<div class="shopleft">
<a href="index.php"> <img src="images/shop.png" alt="" /></a>
</div>
<div class="shopright">
<a href="login.php"> <img src="images/check.png" alt="" /></a>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<?php include 'inc/footer.php'; ?>