-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
421 lines (378 loc) · 16.6 KB
/
checkout.php
File metadata and controls
421 lines (378 loc) · 16.6 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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<?php
session_start();
$servername = "localhost";
$db_username = "your_db_username";
$db_password = "your_db_password";
$dbname = "mbzstore";
$conn = mysqli_connect('localhost', 'root', '', 'mbzstore');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
};
include 'common_functions.php';
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
// Redirect or handle the case where the user is not logged in
header("Location: login.php");
exit();
}
// Get the user_id from the session
// Get the user_id from the session
$user_id = $_SESSION['user_id'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>MBZTECHNOLOGY</title>
<style>
.quantity-control {
display: flex;
align-items: center;
margin-top: 20px;
}
.quantity-button {
background-color: #f0f0f0;
border: none;
color: #333;
font-weight: bold;
font-size: 1.2em;
cursor: pointer;
padding: 5px 10px;
transition: background-color 0.3s;
}
.qq{
margin-right: 20px;
}
.oo{
margin-left: 20px;
}
.quantity-button:hover {
background-color: #ddd;
}
</style>
<?php
$user_ip = getIPAddress();
$get_user = "SELECT * FROM `user_table` WHERE user_id = '$user_id'";
$result = mysqli_query($conn, $get_user);
$run_query = mysqli_fetch_array($result);
$user_id = $run_query['user_id'];
?>
<!-- favicon -->
<link rel=icon href="assets/img/favicon.png" sizes="20x20" type="image/png">
<!-- animate -->
<link rel="stylesheet" href="assets/css/animate.css">
<!-- bootstrap -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<!-- magnific popup -->
<link rel="stylesheet" href="assets/css/magnific-popup.css">
<!-- owl carousel -->
<link rel="stylesheet" href="assets/css/owl.carousel.min.css">
<link rel="stylesheet" href="assets/css/slick.css">
<!-- fontawesome -->
<link rel="stylesheet" href="assets/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/line-awesome.min.css">
<link rel="stylesheet" href="assets/css/themify-icons.css">
<!-- flaticon -->
<link rel="stylesheet" href="assets/css/flaticon.css">
<!-- nice-select -->
<link rel="stylesheet" href="assets/css/nice-select.css">
<!-- animated slider -->
<link rel="stylesheet" href="assets/css/animated-slider.css">
<!-- Main Stylesheet -->
<link rel="stylesheet" href="assets/css/style.css">
<!-- responsive Stylesheet -->
<link rel="stylesheet" href="assets/css/responsive.css">
</head>
<body>
<!-- preloader area start -->
<div class="preloader" id="preloader">
<div class="preloader-inner">
<div class="spinner">
<div class="dot1"></div>
<div class="dot2"></div>
</div>
</div>
</div>
<!-- preloader area end -->
<?php
cart();
?>
<?php
?>
<!-- search Popup -->
<div class="body-overlay" id="body-overlay"></div>
<div class="search-popup" id="search-popup">
<form action="index.php" class="search-form">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search.....">
</div>
<button type="submit" class="submit-btn"><i class="fa fa-search"></i></button>
</form>
</div>
<!-- //. search Popup -->
<!-- breadcrumb area start -->
<div class="breadcrumb-area" style="background-image:url(assets/img/page-title-bg.png);">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="breadcrumb-inner">
<h1 class="page-title">Checkout</h1>
<!-- <ul class="page-list">
<li><a href="index.php">Home</a></li>
<li>Checkout</li>
</ul> -->
</div>
</div>
</div>
</div>
</div>
<!-- breadcrumb area End -->
<div class="checkout-page-area pd-top-120">
<div class="container">
<div class="row">
<div class="col-lg-7">
<div class="checkout-form-wrap">
<div class="checkout-title">
<div class="row">
<div class="col-xl-5 col-lg-12 col-md-6">
<h6>Contact information</h6>
</div>
<!-- <div class="col-xl-7 col-lg-12 col-md-6 text-xl-right text-lg-left text-md-right">
<span>Already have an account?</span>
<a id="signIn-btn" href="#">Sign in /</a>
<a id="signUp-btn" href="#">Sign Up</a>
</div> -->
</div>
</div>
<div class="checkout-form">
<form method="POST" action="https://checkout.flutterwave.com/v3/hosted/pay" id="paymentForm" class="riyaqas-form-wrap">
<div class="row custom-gutters-20">
<div class="col-md-12">
<div class="single-input-wrap">
<input id="customer-email" type="text" class="single-input">
<label>E-mail</label>
</div>
</div>
<div class="col-md-6">
<div class="single-input-wrap">
<input id="customer-first-name" type="text" class="single-input">
<label>First Name</label>
</div>
</div>
<div class="col-md-6">
<div class="single-input-wrap">
<input id="customer-last-name" type="text" class="single-input">
<label>Last Name</label>
</div>
</div>
<div class="col-md-12">
<div class="single-input-wrap">
<input id="customer-address" type="text" class="single-input">
<label>Address</label>
</div>
</div>
<div class="col-md-12">
<div class="single-input-wrap">
<input id="customer-city" type="text" class="single-input">
<label>City</label>
</div>
</div>
<div class="col-md-6">
<div class="single-input-wrap">
<select id="customer-country" class="select single-select">
<option value="" disabled selected>Country</option>
<!-- Africa -->
<option value="EG">Egypt</option>
<option value="NG">Nigeria</option>
<option value="CD">Ghane</option>
<option value="ZA">South Africa</option>
<!-- Asia -->
<option value="CN">China</option>
<option value="JP">Japan</option>
<option value="KR">South Korea</option>
<!-- Europe -->
<option value="FR">France</option>
<option value="DE">Germany</option>
<option value="IT">Italy</option>
<option value="ES">Spain</option>
<option value="GB">United Kingdom</option>
<!-- North America -->
<option value="CA">Canada</option>
<option value="MX">Mexico</option>
<option value="US">United States</option>
<!-- South America -->
<option value="AR">Argentina</option>
<option value="BR">Brazil</option>
<option value="CL">Chile</option>
<option value="CO">Colombia</option>
<option value="PE">Peru</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="single-input-wrap">
<input id="customer-postal-code" type="text" class="single-input">
<label>Postal code</label>
</div>
</div>
<div class="col-md-6">
<div class="single-input-wrap">
<input id="customer-phone" type="text" class="single-input">
<label>Phone</label>
</div>
</div>
<!-- <div class="col-md-12 padding-top-50">
<div class="checkout-title">
<h6>Payment Method</h6>
</div>
<div class="payment-method">
<ul>
<li>
<a href="#"><img src="assets/img/checkout/1.svg" alt="img"></a>
<a href="#"><img src="assets/img/checkout/Flutterwave-New-Logo-2022-Transparent.webp" width="150" alt="img"></a>
</li>
<li><a href="#">Cash On Delivery</a></li>
<li><a href="#">Bank Account Payment</a></li>
</ul>
</div>
</div> -->
<!-- <div class="col-12 text-right">
<a class="btn btn-green" href="error.php">Place Order</a>
</div> -->
</div>
</form>
</div>
</div>
</div>
<!-- HTML -->
<div class="col-lg-5">
<div class="checkout-form-product">
<div class="order-table table-responsive">
<table class="table">
<?php
$get_ip_address = getIPAddress();
$total_price=0;
$cart_query="select * from `cart_details` where ip_address='$get_ip_address'";
$result=mysqli_query($conn,$cart_query);
$result_count=mysqli_num_rows($result);
if($result_count>0){
while($row=mysqli_fetch_array($result)){
$product_id=$row['product_id'];
$select_products="select * from `products` where product_id='$product_id'";
$result_products=mysqli_query($conn,$select_products);
while($row_product_price=mysqli_fetch_array($result_products)){
$product_price=array($row_product_price['product_price']);
$price_table=$row_product_price['product_price'];
$product_title=$row_product_price['product_title'];
$product_image=$row_product_price['product_image'];
$product_values=array_sum($product_price);
$total_price+=$product_values;
?>
<tbody>
<tr>
<td>
<div class="media single-cart-product">
<div class="media-body">
<span id="selected-tier">Tier: <?php echo $product_title?></span><br>
</div>
</div>
</td>
<td class="cart-product-price text-center">
<span id="selected-price">€ <?php echo $price_table?></span>
</td>
</tr>
</tbody>
</table>
<?php
}
}
}
else{
echo"<h7>Your Cart is Empty</h7>";
}
?>
<div class="total-shapping-area-wrap">
<div class="total-shapping-area">
<div class="charge">
<span>Total:</span>
<span id="subtotal" class="amount float-right">€<?php echo $total_price ?></span>
</div>
</div>
</div>
</div>
<br>
<br>
<div class="order-table table-responsive">
<div class="col-md-12 padding-top-50">
<div class="checkout-title">
<h6>Payment Method</h6>
</div>
<div class="payment-method">
<!-- <ul>
<li class="okkk">
<a href="#"><img src="assets/img/checkout/1.svg" alt="Payment Method 1"></a>
<br><br>
<a class="ff" type="submit" id="paymentButton" >
<img src="assets/img/checkout/Flutterwave-New-Logo-2022-Transparent.webp" width="150" alt="img">
</a>
<br>
<br>
<a href="#"><img src="assets/img/checkout/globalpay.jpg" width="100" alt="img"></a>
<br>
<br>
<a href="stripe.html"><img src="assets/img/checkout/R (8).png" width="70" alt="img"></a>
</li>
</ul> -->
</div>
</div>
<div class="col-12 text-left">
<?php
// Add this before generating the link to order.php
?>
<a class="btn btn-green" href="order.php?user_id=<?php echo $user_id; ?>">Place Order</a>
</div>
</div>
</div>
</div>
<!-- footer area start -->
<!-- footer area end -->
<!-- back to top area start -->
<div class="back-to-top">
<span class="back-top"><i class="fa fa-angle-up"></i></span>
</div>
<!-- back to top area end -->
<!-- jquery -->
<script src="assets/js/jquery-2.2.4.min.js"></script>
<!-- popper -->
<script src="assets/js/popper.min.js"></script>
<!-- bootstrap -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- magnific popup -->
<script src="assets/js/jquery.magnific-popup.js"></script>
<!-- wow -->
<script src="assets/js/wow.min.js"></script>
<!-- slider js -->
<script src="assets/js/owl.carousel.min.js"></script>
<script src="assets/js/jquery.cssslider.min.js"></script>
<script src="assets/js/slick.js"></script>
<!-- waypoint -->
<script src="assets/js/waypoints.min.js"></script>
<!-- counterup -->
<script src="assets/js/jquery.counterup.min.js"></script>
<!-- imageloaded -->
<script src="assets/js/imagesloaded.pkgd.min.js"></script>
<!-- isotope -->
<script src="assets/js/isotope.pkgd.min.js"></script>
<!-- nice-select -->
<script src="assets/js/jquery.nice-select.min.js"></script>
<!-- world map -->
<script src="assets/js/worldmap-libs.js"></script>
<script src="assets/js/worldmap-topojson.js"></script>
<script src="assets/js/mediaelement.min.js"></script>
<!-- main js -->
<script src="assets/js/main.js"></script>
</body>
</html>