-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
268 lines (228 loc) · 8.84 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
<?php
// Turn off all error reporting
error_reporting(0);
?>
<?php
// include("db.php");
include("functions/functions.php");
$con=db();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add to cart page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="grid.css"><!--------used as main css file ------->
<link rel="stylesheet" type="text/css" href="cart.css">
<style>
.cart_update_btn{
background: green;
color: white;
border: none;
padding: 5px;
font-size: 15px;
border-radius: 4px;
}
.cart_update_btn:hover{
background: grey;
}
.cart_buynow_a{
text-decoration: none;
background: blue;
color: white;
font-size: 15px;
border-radius: 4px;
padding: 5px;
}
.cart_buynow_a:hover{
background: grey;
}
#emailchek{
margin-left: 30px;
color:red;
}
@media only screen and (max-width: 560px) {
#emailchek{
margin-left: 5px;
font-size: 95%;
margin-top: 5px;
}
}
</style>
</head>
<body>
<div class="header"><!------ header starts----->
<div class="header1"><!---- header1 starts ------>
<h6 class="div1h6">India's Fastest Online Shopping Destination</h6>
<ul>
<li><span style='font-size:25px;'>☰</span>
<ul>
<li><a href="">Gift Card</a></li>
<li><a href="">Kerala Flood Relief</a></li>
<li><a href="">Gift Card</a></li>
<li><a href="">Sell On Easy Shoppi</a></li>
<li><a href="">  Download App</a></li>
</ul>
</li>
</ul>
</div><!---- header1 ends ------>
<div class="header2"><!---- header2 starts ------>
<img src="images/logos/logo.png">
<h5>EASY SHOPPING.COM</h5>
<div class="searchcontainer">
<div class="searchbox">
<form action="" method="post">
<input type="text" name="searchbox" id="searchtextf" placeholder="Search Anything .......">
<button type="submit" name="searchsubmit" style="">🔍<i class="button_i">Search</i></button>
</form>
</div>
<div class="mainsearcha">
<?php getProsearch(); ?>
</div>
</div>
<div class="loginsignin" style="margin-top: 15px; color: white; "><!---- log in with php starts ------>
<?php
include 'login-signup-page1/logincheck.php';
if( isset($_SESSION['removelogin']) && !empty($_SESSION['removelogin']) )
{
?>
<div class="useracc">
<ul>
<li><p class="userpre"><?php echo $_SESSION['username'] ?>
<ul>
<li style=""><a href="my_account.php">Account</a></li>
<li style=""><a href="settings.php">Settings</a></li>
<li style=""><a href="login-signup-page1/logout.php">Logout</a></li>
</ul>
</li>
</ul>
<!--- <p class="userpre"><?php echo $_SESSION['username'] ?></p> -->
<div >
</div>
</div>
<?php }else{ ?>
<a href="login-signup-page1/login-signup.php">Login</a>
<?php } ?>
</div><!---- log in with php ends ------>
</div><!---- header2 endss ------>
</div><!------ header ends----->
<div class="backtoprevious">
<div class="btp">
<a href="specifictypeproduct.php" id="shop11">Shop</a>
<p id="slash11">|</p>
<a href="index.php" id="b2home" class="b2hc" style="color: #00b7ff;">Home</a>
<p>></p>
<a href="cart.php" id="b2cart" class="b2hc">Cart</a>
</div>
</div>
<div class="cartcontainer">
<div class="ccontainer1">
<p id="cc1p1">Shopping Cart</p>
<?php
if (isset($_SESSION['email'])) {
$ip_add =getrealipuser();
$check_email=$_SESSION['email'];
$connection_cart="select * from cart where email='$check_email'";
// $connection_cart="select * from cart where ip_add='$ip_add'";
$run_cart=mysqli_query($con,$connection_cart);
$count=mysqli_num_rows($run_cart);
}
?>
<?php if (!isset($_SESSION['email'])) { echo "<h1 id='emailchek'>Please Login!</h1>"; } ?>
<p id="cc1p2">You currently have <?php if (isset($_SESSION['email'])) { echo $count; }else{ } ?> items in your cart</p>
<form action="cart.php" method="post" enctype="multipart/form-data">
<div class="cartbox">
<table class="carttable">
<tr id="table_tr">
<th id="table_th1" ><p>Product</p></th>
<th id="table_th2"><p >Name</p></th>
<th id="table_th3"><p>Quantity</p></th>
<th id="table_th4"><p>Price</p></th>
<th id="table_th5"><p>Total</p></th>
<th id="table_th6"><p>Delete</p></th>
</tr>
<?php
if (isset($_SESSION['email'])) {
$total=0;
while ( $row_cart=mysqli_fetch_array($run_cart)) {
$pro_id=$row_cart['p_id'];
$pro_qty=$row_cart['qty'];
$check_email=$_SESSION['email'];
$get_products= "select * from products where 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'];
$product_price=$row_products['product_price'];
$Sub_total=$product_price*$pro_qty;
$total+=$Sub_total;
}
?>
<tr id="table_tr2" >
<th class="img_th"><img src="products/<?php echo $product_img1 ?>" alt=""></th>
<th><a href="product.php?pro_id=<?php echo $pro_id ?>" class="table_tr2a"><?php echo $product_title ?></a></th>
<th><input type="number" class="quantity" value="<?php echo $pro_qty ?>"></th>
<th><p>Rs <?php echo $product_price ?></p></th>
<th><p>RS <?php echo $Sub_total ?></p></th>
<!---<th><button class="remove_btn"><p>Remove</p></button></th> ----->
<th><input id='checkb' type="checkbox" name="remove[]" onKeyPress="javascript:update(this);" value="<?php echo $pro_id; ?>"></th>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</tr>
<?php } } ?>
</table>
<center>
<table class="buytable">
<tr id="buytabletr">
<th id="buytableth1"><p>Total</p></th>
<th id="buytableth2"><p>Rs <?php if (isset($_SESSION['email'])) { echo $total; }else{echo "00000";} ?></p></th>
<th id="buytableth3"><button type="submit" name="update" class="cart_update_btn" ><p>Update Cart</p></button></th>
<th id="buytableth3"><a class="cart_buynow_a" href="<?php if (isset($_SESSION['email'])) { if($total!=0){echo "checkout.php";}} ?>">Checkout</a></th>
</tr>
</table>
</center>
</div>
</form>
</div>
<?php
function update_cart(){
// $db=mysqli_connect('localhost','root',"","website");
if(isset($_POST['update'])){
$check_email=$_SESSION['email'];
foreach($_POST['remove'] as $remove_id) {
$delete_product="delete from cart where p_id='$remove_id' AND email='$check_email'";
$run_delete=mysqli_query(db(),$delete_product);
if ($run_delete) {
echo "<script>window.open('cart.php','_self') </script>";
}
else{
echo "<script>alert('error')</script>";
}
}
}
}
echo @$up_cart=update_cart();
?>
<div class="ccontainer2">
<center>
<p class="cc2p1">Order Summery</p>
</center>
<center>
<p class="cc2p2">Shipping and additional cost will be calculated based on value you have entered</p>
</center>
<p class="cc2p3"> <strong>Order Sub-total :</strong> Rs <?php if (isset($_SESSION['email'])) { echo $total; }else{echo "00000";} ?></p>
<p class="cc2p4"> <strong>Shipping and Handling :</strong> Rs 0</p>
<p class="cc2p5"> <strong>Tax :</strong> Rs 0</p>
<p class="cc2p6"> <strong>Total :</strong> Rs <?php if (isset($_SESSION['email'])) { echo $total; }else{echo "00000";} ?></p>
</div>
</div>
<div class="footer"><!------ footer starts------->
<div class="footerp1 footerp">
<p>Copyright © 2017, EasyShopping Private Limited. All Rights Reserved</p>
</div>
<div class="footerp2 footerp">
<p>Made with ❤ in india</p>
</div>
</div><!------ footer Ends------->
</body>
</html>