-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.php
163 lines (117 loc) · 5.33 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
<?php
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");
//Tell PHP to log errors
ini_set('log_errors', 'On');
//Tell PHP to not display errors
ini_set('display_errors', 'Off');
//Set error_reporting to E_ALL
ini_set('error_reporting', E_ALL );
include '_dbConnect.php';
// Start the session
session_start();
$grand_total = 0;
$allItems = '';
$items = [];
$uid = $_SESSION['uid'];
$sql = "SELECT CONCAT(product_name, '(',qty,')') AS ItemQty, total_price FROM cart WHERE uid='$uid'";
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$grand_total += $row['total_price'];
$items[] = $row['ItemQty'];
}
$allItems = implode( "<br>" , $items);
$oid = mt_rand(1111,9999);
$_SESSION['oid'] = $oid;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Tab Icon -->
<link rel="icon" href="assests/images/logo.png" type="image/icon type">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
<link rel='stylesheet'
href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css' />
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css">
<link rel="stylesheet" href="assests/css/style.css">
<link rel="stylesheet" href="assests/css/Product.css">
<title>Checkout</title>
</head>
<body>
<!-- header section -->
<header id="topheader" style="background:black">
<?php include 'header.php'; ?>
<?php include 'login_signup.php'; ?>
</header>
<!-- header section ends -->
<!-- ******************************************************************************************************** -->
<div class="container" style=' margin-top: 160px'>
<div class="row justify-content-center">
<div class="col-lg-6 px-4 pb-4" id="order">
<h2 class="text-center p-2">Complete your order!</h2>
<div class="jumbotron p-3 mb-2 text-center">
<h6 class="lead"><b>Product(s) : </b><?php echo $allItems; ?></h6>
<h6 class="lead"><b>Delivery Charge : </b>Free</h6>
<h5><b>Total Amount Payable : </b><?= number_format($grand_total,2) ?>/-</h5>
</div>
<form action="reciept.php" method="post" id="placeOrder">
<input type="hidden" name="products" class="form-control" value="<?= $allItems; ?>">
<input type="hidden" name="TXN_AMOUNT" class="form-control" value="<?= $grand_total; ?>">
<input type="hidden" name="ORDER_ID" class="form-control" value="<?php echo'OD'.$oid; ?>">
<input type="hidden" name="CUST_ID" class="form-control" value="<?php echo'CUST'.$uid; ?>">
<div class="form-group">
<input type="text" name="name" class="form-control" value="<?= $_SESSION['uname']?>" required>
</div>
<div class="form-group">
<input type="email" name="email" class="form-control" value="<?= $_SESSION['email']?>" required>
</div>
<div class="form-group">
<input type="tel" name="phone" class="form-control" placeholder="Enter Contact Number" required>
</div>
<div class="form-group">
<textarea name="address" class="form-control" rows="3" cols="10"
value="<?= $_SESSION['address']?>"></textarea>
</div>
<div class="form-group">
<input type="submit" name="submit" value="Place Order" class="btn btn-success btn-block">
</div>
</form>
</div>
</div>
</div>
<!-- footer section -->
<?php include 'footer.php'; ?>
<script src="assests/js/main.js"></script>
<!-- Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous">
</script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.min.js'></script>
<script type="text/javascript">
$(document).ready(function() {
// Load total no.of items added in the cart and display in the navbar
load_cart_item_number();
function load_cart_item_number() {
$.ajax({
url: 'action.php',
method: 'get',
data: {
cartItem: "cart_item"
},
success: function(response) {
$("#cart-item").html(response);
}
});
}
});
</script>
</body>
</html>