-
Notifications
You must be signed in to change notification settings - Fork 1
/
checkout.php
213 lines (177 loc) · 5.49 KB
/
checkout.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="assets/images/favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Poppins:100,200,300,400,500,600,700,800,900&display=swap" rel="stylesheet">
<!-- Bootstrap core CSS -->
<link href="../dist/frontendcss/bootstrap.min.css" rel="stylesheet">
<!-- Additional CSS Files -->
<link rel="stylesheet" href="../dist/frontendcss/fontawesome.css">
<link rel="stylesheet" href="../dist/frontendcss/style.css">
<link rel="stylesheet" href="../dist/frontendcss//owl.css">
<link rel="shortcut icon" href="images/favicon-icon/24x24.png">
</head>
<style>
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
max-width: 300px;
text-align: center;
float: left;
margin-left: 32px;
}
.card button {
border: none;
outline: 0;
padding: 12px;
color: white;
background-color: #000;
text-align: center;
cursor: pointer;
width: 100%;
font-size: 18px;
}
table, th, tr{
text-align: center;
}
.title2{
text-align: center;
background-color: #000;
color: #66afe9;
padding: 2%;
}
table th{
background-color: #efefef;
}
</style>
<body>
<?php
session_start();
include('dbcon_1.php');
if(isset($_POST["shopping_cart"])){
if($_SESSION["cart"]){
$item_array_id=array_column($_SESSION["cart"],"productid");
if (!in_array($_GET["productid"], $item_array_id)) {
$count=count($_SESSION["cart"]);
$item_array=array(
'productid' => $_GET['productid'],
'productname' => $_POST['productname'],
'productprice' => $_POST['productprice'],
'productquantity' => $_POST['productquantity']
);
$_SESSION["cart"][$count]=$item_array;
echo '<script>window.location="productswomen.php"</script>';
}
else {
echo '<script>alert("Product is already added to Cart!")</script>';
echo '<script>window.location="productswomen.php"</script>';
}
}
else{
$item_array=array(
'productid' => $_GET["productid"],
'productname' => $_POST["productname"],
'productprice' => $_POST["productprice"],
'productquantity' => $_POST["productquantity"]
);
$_SESSION["cart"][0]=$item_array;
}
}
if (isset($_GET["action"])) {
if ($_GET["action"]=="delete") {
foreach ($_SESSION["cart"] as $key => $value) {
if ($value["productid"]==$_GET["productid"]) {
unset($_SESSION["cart"][$keys]);
echo '<script> alert("Product has been removed..!")</script>';
echo '<script>window.location=productswomen.php</script>';
}
}
}
}
?>
<form >
<!-- ***** Preloader End ***** -->
<?php
include './headerfront.php';
?>
<!-- Page Content -->
<?php
include 'dbcon.php';
$query="select * from product where productgender='Male'";
$result=mysqli_query($conn,$query);
$run=mysqli_num_rows($result)>0;
if($run)
{
while ( $row=mysqli_fetch_array($result)) {
?>
<form method="post" action="productswomen.php?action=shopping_cart&id=<?php echo$row['productid'] ?>" >
<div class="container py-5">
<div class col-md-3>
<div class="card" >
<div class="card-body">
<img src="<?php echo $row['productimage']; ?> " class="card-img-top" height="200" width="300" >
<h2 class="card-title"><?php echo $row['productname']; ?> </h2>
<h3 class="card-title"><?php echo $row['productsize']; ?></h3>
<h4 class="card-title"><?php echo $row['productprice']; ?></h4>
<button name="shopping_cart" >Add to Cart</button>
</div>
</div>
</div>
</div>
<?php
}
}
else{
echo "No data found";
}
?>
</form>
<div style="clear: both">
<h3 class="title2">Shopping Cart Details</h3>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th width="30%">Product Name</th>
<th width="30%">Quantity</th>
<th width="30%">Price Details</th>
<th width="30%">Total Price</th>
<th width="30%">Remove Item</th>
</tr>
<?php
if (!empty($_SESSION["cart"])) {
$total=0;
foreach ($_SESSION["cart"] as $key => $value) {
?>
<tr>
<td><?php echo $value["productname"]; ?></td>
<td><?php echo $value["productquantity"];?></td>
<td><?php echo $value["productprice"];?></td>
<td><?php echo number_format($value["productquantity"]* $value["productprice"]); ?></td>
<td><a href="productswomen.php?action=delete&id=<?php echo $value['productid']; ?>"><span class="text-danger">Remove Item</span></a> </td>
</tr>
<?php
$total =$total +($value["productquantity"] * $value["productprice"]);
}
?>
<tr>
<td colspan="3" align="right">Total </td>
<th align="right">RS<?php echo number_format($total); ?></th>
<td></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Additional Scripts -->
<script src="assets/js/custom.js"></script>
<script src="assets/js/owl.js"></script>
</body>
</html>