-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
251 lines (200 loc) · 7.53 KB
/
Copy pathcheckout.php
File metadata and controls
251 lines (200 loc) · 7.53 KB
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
<?php
include "php/db.php";
require "php/indexC.php";
session_start();
print_r($_SESSION['deals']);
if(!isset($_SESSION["cart"])){
$_SESSION["x"] = serialize(new Kart());
}
if(!isset($_SESSION["user"])){
header("Location:login.php");
}
$c = new Catlog();
$navs = $c->getCategories($conn);
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href='css/index.css' type='text/css' rel='stylesheet'>
<title>Welcome to amazon</title>
</head>
<body>
<div class="container-fluid">
<div class="row topBar">
<div class="col-2">
<nav class="navbar ">
<a class="navbar-brand" href="#">
<img src="img/home/logo.png" class="rounded float-left mainLogo" alt="">
</a>
</nav>
</div>
<div class="col-8">
<!---
<form class="form-inline" style="margin-top: 20px">
<input class="form-control" style="width: 60%;margin:0 auto" type="search" placeholder="Search" aria-label="Search">
</form>
-->
</div>
<div class="col-sm">
<div class="text-center">
<a href="kart.php"><img src="img/home/cart.png" id="cart" class="bxt"></a>
<span class="badge badge-danger" style="position:relative; top:30px;right:40px;"><?php echo count($_SESSION['cart'])?></span>
</div>
</div>
</div>
</div>
<div class="container-fluid bg-dark">
<nav class="navbar navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="#"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="home.php">Home</a>
</li>
<?php
foreach($navs as $x)
{
$active ="";
echo "
<li class='nav-item'>
<a class='nav-link $active' href='cat.php?c=$x'>$x</a>
</li>
<?php
";
}
?>
</ul>
</div>
</nav>
</div>
<div class="container-fluid">
<!-- content -->
<div class="row">
<div class="col-8">
<?php
$obj = unserialize($_SESSION["x"]);
$p = $obj->getNoItems();
$sum =0;
if($p > 0){
$x = $obj->caluculatePrice($conn);
foreach($x as $q){
$sum = $sum + $q->price;
echo "
<div class='row bord' style='margin-top: 5px; padding:50px;'>
<div class='col-3'>
<img src='$q->image' class='img-thumbnail'>
</div>
<div class='col-6 text-center'>
<h4 style='margin: 10px;'>$q->pname</h4>
</div>
<div class='col-3 text-center'>
<h1>$$q->price</h1>
<strong style='position:relative;top:13px;'>Quantity: $q->qty </strong>
<br>
<br>
</div>
</div>
";
}
}
?>
<div class="row" style="margin-top: 20px;">
<div class="col-8 text-center">
</div>
<div class="col-4">
<h1 style="display:inline-block">Total : $<?php echo $sum;?></h1>
</div>
</div>
</div>
<div class="col-4">
<div class="row">
<div class="col">
<h3>Payment Options</h3>
</div>
</div>
<div class='row'>
<div class="col">
<div class="alert alert-danger" id="feed" role="alert">
A simple danger alert—check it out!
</div>
</div>
</div>
<div class="row">
<div class="col-8 ">
<textarea id="address" class="form-control" style="resize:none;"placeholder="Enter Address" row="5"></textarea>
</div>
</div>
<div class="row">
<div class="col-8 ">
<select name="categorySelect" class="custom-select my-1 mr-sm-2" id="optionSelect">
<option value=0>Choose...</option>
<!--<option value=1>Upi</option>-->
<option value=2>Pay from Amazon Balance</option>
<option value=3>Cash on delivery</option>
</select>
</div>
</div>
<div class="row" style="margin-top:20px;">
<div class="col-8 " id="outForm">
</div>
</div>
<div class="row" style="margin-top:20px;">
<div class="col-12 text-center">
<button class="btn btn-warning bxt payButton">Pay</button>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid bg-dark text-light" style="padding: 20px;margin-top:50px;">
<div class='row text-center' >
<span style="margin: 0 auto;">@Ngit Software Engineering Project</span>
</div>
</div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
var s = <?php echo sizeof($_SESSION["cart"]);?>;
if(s == 0){
window.location.href = "home.php";
}
var feed = $("#feed").parent().parent().hide();
$("#optionSelect").on("change",function(){
var val = $(this).val();
if(val == 0){
$("#feed").html("<strong>Please choose payment option</strong>");
feed.show();
return;
}
$.post("php/checkop.php",{val:val},function(data){
$("#outForm").html(data);
});
});
$(".payButton").click(function(){
var address = $("#address").val();
if(address.length ==0){
$("#feed").html("Please Enter address");
feed.show();
return;
}
var val = $("#optionSelect").val();
if(val == 0){
$("#feed").html("<strong>Please choose payment option</strong>");
feed.show();
return;
}
var tot=<?php echo $sum;?>;
$.post("php/checkop.php",{address:address,mode:val,total:tot},function(data){
$("#feed").html(data);
feed.show();
});
});
});
</script>
</html>