-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
160 lines (140 loc) · 4.98 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
<?php
session_start();
if(isset($_SESSION['cart'])){
$local_cart=$_SESSION['cart'];
$count=count($local_cart);
}
else{
$count=0;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<link rel="stylesheet" href="home.css">
<script defer src="https://use.fontawesome.com/releases/v5.15.4/js/all.js"></script>
<style>
.cart-count{
width:20px;
height:20px;
border-radius:50%;
background-color:azure;
padding:4px;
position:absolute;
right:-2px;
top:-10px;
font-weight:bold;
}
</style>
</head>
<body>
<section id="header">
<a href="#"><img src="../images/Logo/logo1.png" class="logo" alt=""></a>
<div>
<ul id="navbar">
<li><a href="home.php">Home</a></li>
<li><a href="shop.php">Shop</a></li>
<li><a href="blog.html">Blog</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact Us</a></li>
<li id="lg-bag"><a class="active" href="cart.php"><i class="fa fa-shopping-bag"></i></a>
<span class="cart-count"><?php
echo "$count";
?></span>
</li>
<li><a href="logout.php">Logout</a></li>
<a href="#" id="close"><i class="fa fa-times"></i></a>
</ul>
</div>
<div id="mobile">
<a href="cart.php"><i class="fa fa-shopping-bag icon1"></i></a>
<button id="bar"><i class="fas fa-outdent icon1"></i></button>
</div>
</section>
<section id="page-header">
<h2>#stayhome</h2>
<p>Save more with coupons and up to 70% off ! </p>
</section>
<section id="cart" class="section-p1">
<table width="100%">
<thead>
<tr>
<td>Remove</td>
<td>Image</td>
<td>Product</td>
<td>Price</td>
<td>Quantity</td>
</tr>
</thead>
<?php
$total=0;
echo "<tbody>";
if(!isset($_SESSION['cart']) || empty($_SESSION['cart'])){
echo "<center><h3 style='margin-bottom:50px;margin-top:40px;'>Cart is Empty!</h3></center>";
}
else{
$local_cart=$_SESSION['cart'];
include_once "../shared/connection.php";
$pids=implode(",",$local_cart);
$cmd="select * from products where pid in($pids)";
$sqli_obj=mysqli_query($conn,$cmd);
while($row=mysqli_fetch_assoc($sqli_obj)){
$imname=$row['impath'];
$name=$row['name'];
$price=$row['price'];
$pid=$row['pid'];
echo "<tr>
<td><a href='remove_cart.php?pid=$pid'><i class='far fa-times-circle'></i></a></td>
<td><img src='$imname' alt=''></td>
<td>$name</td>
<td>$$price</td>
<td><input type='number' value='1'></td>
</tr>";
$total+=$price;
}
}
echo "</tbody>
</table>
</section>
<hr>
<section id='product1' class='section-p1'>
<div class='pro-container'>
<div class='pro'>
<h4><span style='font-style:bold;'>TOTAL AMOUNT : </span>$$total<h4>
</div>
<a style='text-decoration:none;' href='payment_form.php'><div class='pro' style='border-radius:0px;display:cover;'>
<h4>Proceed To Pay</h4>
</div></a>
</div>
</section>
<hr>";
?>
<footer class="section-p1">
<div class="col follow">
<h4>Follow Us</h4>
<div class="icons">
<i class="fab fa-facebook-f icon"></i>
<i class="fab fa-twitter icon"></i>
<i class="fab fa-instagram icon"></i>
<i class="fab fa-youtube icon"></i>
</div>
</div>
<div class="col">
<h4>About Us</h4>
<a href="#">Delivery Information</a>
<a href="#">Privacy Policy</a>
<a href="#">Terms and conditions</a>
<a href="#">Contact us</a>
</div>
<div class="col">
<h4>My Account</h4>
<a href="#">View Cart</a>
<a href="#">My Orders</a>
<a href="#">Help</a>
</div>
</footer>
<p class="copyright section-p1">©SMart 2022</p>
<script src="home.js"></script>
</body>
</html>