-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
162 lines (157 loc) · 5.09 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
<?php include 'includes/header.php'; ?>
<?php
if (isset($_GET['delpro'])) {
$delId = preg_replace('[^A-Za-z0-9_]', '', $_GET['delpro']);
$delProduct = $ct->delProductByCart($delId);
}
?>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$cartId = $_POST['cartId'];
$quantity = $_POST['quantity'];
$updateCart = $ct->updateCartQuantity($cartId, $quantity);
if ($quantity <= 0) {
$delProduct = $ct->delProductByCart($cartId);
}
}
?>
<?php
if (!isset($_GET['id'])) {
echo "<meta http-equiv='refresh' content='0;URL=?id=eGohona'/>";
}
?>
<!-- Page info -->
<div class="container" style="margin-top: 30px;">
<div class="page-top-info">
<div class="breadcrumb"> <a href="index.html">Home </a> » <a href="#">Clothes For Girls </a> </div>
<div class="section-title">
<h3><span>Your Cart</span></h3>
</div>
</div>
</div>
<!-- Page info end -->
<!-- cart section end -->
<section class="cart-section spad">
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="cart-table">
<?php
$getData = $ct->checkCartTable();
if ($getData) {
?>
<div class="cart-table-warp">
<?php
if (isset($updateCart)) {
echo $updateCart;
}
if (isset($delProduct)) {
echo $delProduct;
}
?>
<table>
<thead>
<tr>
<th class="product-th">Product</th>
<th class="quy-th">Quantity</th>
<th class="size-th">Price</th>
<th class="total-th">Total</th>
</tr>
</thead>
<tbody>
<?php
$getPro = $ct->getCartProduct();
if ($getPro) {
$i = 0;
$sum = 0;
$qty = 0;
while ($result = $getPro->fetch_assoc()) {
$i++;
?>
<tr>
<td class="product-col">
<img src="admin/<?= $result['product_image']; ?>" alt="">
<div class="pc-title">
<h4><?= $result['product_name']; ?></h4>
<p><?= $result['product_price']; ?></p>
</div>
</td>
<td class="quy-col">
<div class="quantity">
<form action="" method="POST">
<input type="hidden" name="cartId" value="<?php echo $result['id']; ?>"/>
<div class="pro-qty">
<input type="text" name="quantity" value="<?= $result['product_qty']; ?>"> <br>
</div>
<button title="Update Quantity" class="icon" type="submit" name="submit"><i class="fa fa-refresh"></i></button>
<a title="Delete from cart" class="icon" onclick="return confirm('Are you sure to delete !')" href="?delpro=<?php echo $result['id']; ?>"><i class="fa fa-times"></i></a>
</form>
</div>
</td>
<td class="size-col"><h4>TK. <?= $result['product_price']; ?></h4></td>
<td class="total-col"><h4>TK. <?php
$total = $result['product_price'] * $result['product_qty'];
echo $total;
?></h4></td>
</tr>
<?php
$sum = $sum + $total;
$qty = $qty + $result['product_qty'];
Session::set("qty", $qty);
Session::set("sum", $sum);
?>
<?php } } ?>
</tbody>
</table>
</div>
<div class="total-cost">
<h6>Total <span>TK. <?php echo $sum; ?></span></h6>
</div>
<?php } else {
echo "<div class='empty-cart'>
<p>Cart Empty! Please add product to cart.</p>
<a href='index.php' style='color:#fff; padding: 10px 20px;' class='site-btn'>Continue Shopping</a>
</div>
";
} ?>
</div>
</div>
<div class="col-lg-4 card-right">
<a href="checkout.php" class="site-btn">Proceed to checkout</a>
<a href="category.php" class="site-btn sb-dark">Continue shopping</a>
</div>
</div>
</div>
</section>
<!-- cart section end -->
<!-- Related product section -->
<section class="related-product-section">
<div class="container">
<div class="section-title text-uppercase">
<h2><span>CONTINUE SHOPPING</span></h2>
</div>
<div class="product-slider owl-carousel" style="display: inline-block;">
<?php
$getRelatedPd = $pd->getAllProduct();
if ($getRelatedPd) {
while ($result = $getRelatedPd->fetch_assoc()) {
?>
<div class="product-item">
<div class="pi-pic">
<a href=""><img src="admin/<?= $result['product_img']; ?>" alt=""></a>
</div>
<div class="pi-text">
<a href=""><p class="pi-title"><?= $result['product_title']; ?></p></a>
<p class="pi-desc"><?= substr($result['product_desc'], 0, 80) ?></p>
<h6><?= $result['new_price'] ?> <span class="old-price"> <?= $result['regular_price'] ?></span></h6>
<div class="pi-links">
<a href="product.php?id=<?= $result['id'] ?>" class="add-card"><i class="flaticon-bag"></i><span>VIEW DETAILS</span></a>
</div>
</div>
</div>
<?php } }?>
</div>
</div>
</section>
<!-- Related product section end -->
<?php include 'includes/footer.php'; ?>