-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.php
287 lines (223 loc) · 8.02 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
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
<!DOCTYPE html>
<html lang="en">
<?php
include('header.php');
?>
<?php
include('navigation.php');
?>
<?php
//fixed variables
$Total_amount = 0;
$Discount = 0;
?>
<?php
if (isset($_SESSION['item_total'])) {
$item_total = $_SESSION['item_total'];
}
if (isset($_SESSION['item_quantity'])) {
$item_quantity = $_SESSION['item_quantity'];
}
if (is_customer() == true) {
$cus_id = $_SESSION['customer_id'];
$stmt = query("SELECT u1.name,c1.mobile_number,c1.email,c1.address,c1.city,c1.zipcode
FROM users u1
JOIN customers c1
ON c1.user_id = u1.user_id
WHERE c1.customer_id = {$cus_id}");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$customer_name = $row['name'];
$customer_mobile_number = $row['mobile_number'];
$customer_address = $row['address'];
$customer_email = $row['email'];
$customer_city = $row['city'];
$customer_zipcode = $row['zipcode'];
}
//generate unique pincodes and numbers
$order_pin_code = generatePinCode();
$identify_num = generateKey();
?>
<section class="ftco-section">
<div class="container">
<div class="row">
<div class="col-xl-8 ftco-animate">
<h1 style="text-align:center;font-size:24px">CHECKOUT</h1>
<form action="checkout_hosted.php" method="post" class="p-3 billing-form ftco-bg-dark p-md-5">
<h3 class="mb-4 billing-heading">Billing Details</h3>
<div class="row align-items-end">
<div class="col-md-12">
<div class="form-group">
<label for="firstname">Name</label>
<input type="text" class="form-control" name="customer_name" value="<?php echo $customer_name; ?>" placeholder="Enter your name">
</div>
</div>
<div class="w-100"></div>
<div class="w-100"></div>
<div class="col-md-6">
<div class="form-group">
<label for="streetaddress">Street Address</label>
<input type="text" class="form-control" name="customer_address" value="<?php echo $customer_address; ?>" placeholder="House number and street name">
</div>
</div>
<div class="w-100"></div>
<div class="col-md-6">
<div class="form-group">
<label for="towncity">Town / City</label>
<input type="text" class="form-control" name="customer_state" value="<?php echo $customer_city; ?>" placeholder="provide a valid state">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="postcodezip">Postcode / ZIP *</label>
<input type="text" class="form-control" name="zip_code" value="<?php echo $customer_zipcode; ?>" placeholder="Zip code required.">
</div>
</div>
<div class="w-100"></div>
<div class="col-md-6">
<div class="form-group">
<label for="phone">Phone</label>
<input type="text" class="form-control" name="customer_mobile" value="<?php echo $customer_mobile_number; ?>" placeholder="Your Mobile number is required.">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="emailaddress">Email Address</label>
<input type="text" class="form-control" name="customer_email" value="<?php echo $customer_email; ?>" placeholder="Please enter a valid email address">
</div>
</div>
<div class="w-100"></div>
<div class="custom-control custom-checkbox">
<input type="hidden" value="<?php echo $item_quantity; ?>" name="items" required />
<!-- amount (total amount => put the variable in value) -->
<input type="hidden" value="<?php echo $item_total; ?>" name="amount" id="total_amount" required /> <!-- will be changed -->
<input type="hidden" value="<?php echo $ship_date = date("Y-m-d H:i:s"); ?>" name="ship_date" id="total_amount" required />
<input type="hidden" value="<?php echo $_SESSION['customer_id']; ?>" name="customer_id" id="cust_id" required />
<input type="hidden" value="<?php echo $order_pin_code; ?>" name="customer_pin_code" id="cust_pin" required />
<input type="hidden" value="<?php echo $identify_num; ?>" name="customer_identify_num" id="order_identify" required />
</div>
<button class="btn btn-primary btn-lg btn-block" type="submit">Place an Order</button>
</div>
</form>
<div class="pt-3 mt-5 row d-flex">
<div class="col-md-6 d-flex">
<div class="p-3 cart-detail cart-total ftco-bg-dark p-md-4">
<h3 class="mb-4 billing-heading">Cart Total</h3>
<p class="d-flex">
<span>Subtotal</span>
<span>৳
<?php
//get total amount of cart --- stored in a session
if (isset($_SESSION['item_total'])) {
$item_total = $_SESSION['item_total'];
} else {
$item_total = $_SESSION['item_total'] = "0";
}
echo $item_total;
?></span>
</p>
<p class="d-flex">
<span>Quantity Bought</span>
<span>
<?php
//get total number of items in cart --- stored in a session
if (isset($_SESSION['item_quantity'])) {
$item_quantity = $_SESSION['item_quantity'];
} else {
$item_quantity = $_SESSION['item_quantity'] = "0";
}
echo $item_quantity;
?></span>
</p>
<p class="d-flex">
<span>Discount</span>
<span>৳<?php echo " " . $Discount; ?></span>
</p>
<hr>
<p class="d-flex total-price">
<span>Total</span>
<span>৳
<?php
$Total_amount = $item_total - $Discount;
echo $Total_amount;
?></span>
</p>
</div>
</div>
</div>
</div>
<div class="col-xl-4 sidebar ftco-animate">
<!-- Search bar -->
<div class="sidebar-box">
<form action="#" class="search-form">
<div class="form-group">
<div class="icon">
<span class="icon-search"></span>
</div>
<input type="text" class="form-control" placeholder="Search...">
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<?php
include('footer.php');
?>
<div id="ftco-loader" class="show fullscreen"><svg class="circular" width="48px" height="48px">
<circle class="path-bg" cx="24" cy="24" r="22" fill="none" stroke-width="4" stroke="#eeeeee" />
<circle class="path" cx="24" cy="24" r="22" fill="none" stroke-width="4" stroke-miterlimit="10" stroke="#F96D00" />
</svg></div>
<script src="js/jquery.min.js"></script>
<script src="js/jquery-migrate-3.0.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.easing.1.3.js"></script>
<script src="js/jquery.waypoints.min.js"></script>
<script src="js/jquery.stellar.min.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script src="js/jquery.magnific-popup.min.js"></script>
<script src="js/aos.js"></script>
<script src="js/jquery.animateNumber.min.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
<script src="js/jquery.timepicker.min.js"></script>
<script src="js/scrollax.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBVWaKrjvy3MaE7SQ74_uJiULgl1JY0H2s&sensor=false"></script>
<script src="js/google-map.js"></script>
<script src="js/main.js"></script>
<script>
$(document).ready(function() {
var quantitiy = 0;
$('.quantity-right-plus').click(function(e) {
// Stop acting like a button
e.preventDefault();
// Get the field name
var quantity = parseInt($('#quantity').val());
// If is not undefined
$('#quantity').val(quantity + 1);
// Increment
});
$('.quantity-left-minus').click(function(e) {
// Stop acting like a button
e.preventDefault();
// Get the field name
var quantity = parseInt($('#quantity').val());
// If is not undefined
// Increment
if (quantity > 0) {
$('#quantity').val(quantity - 1);
}
});
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-23581568-13"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-23581568-13');
</script>
</body>
</html>