-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder_process.php
More file actions
116 lines (106 loc) · 4.15 KB
/
Copy pathorder_process.php
File metadata and controls
116 lines (106 loc) · 4.15 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
<?php
session_start();
include('./functions/common_function.php');
include('./db_connection.php'); // Include your database connection file
if (!isLoggedIn()) {
header("Location: ../coustomer_loging.php");
exit();
}
if (!isset($_GET['order_id'])) {
header("Location: cart.php");
exit();
}
$order_id = $_GET['order_id'];
// Retrieve order details
$query = "SELECT total_amount FROM `order` WHERE order_id = ?";
$stmt = mysqli_prepare($conn, $query);
mysqli_stmt_bind_param($stmt, "i", $order_id);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $total_amount);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Record payment
$payment_id = recordPayment($order_id, $total_amount);
// Optional: Handle installments
$installment_number = 1; // Example installment number
$installment_amount = $total_amount / 3; // Example installment amount, modify as needed
addInstallment($payment_id, $installment_number, $installment_amount);
// Clear the cart after successful payment
clearCart();
// Redirect to a thank you page or order summary
header("Location: thank_you.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Payment</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h2 class="mt-5">Payment</h2>
<form action="payment.php?order_id=<?php echo $order_id; ?>" method="post">
<div class="mb-3">
<label for="card_number" class="form-label">Card Number</label>
<input type="text" class="form-control" id="card_number" name="card_number" required>
</div>
<div class="mb-3">
<label for="card_expiry" class="form-label">Expiry Date</label>
<input type="text" class="form-control" id="card_expiry" name="card_expiry" required>
</div>
<div class="mb-3">
<label for="card_cvv" class="form-label">CVV</label>
<input type="text" class="form-control" id="card_cvv" name="card_cvv" required>
</div>
<h4 class="mt-4">Order Total: $<?php echo number_format($total_amount, 2); ?></h4>
<button type="submit" class="btn btn-primary mt-3">Make Payment</button>
</form>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Process</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h2 class="mt-5">Checkout</h2>
<form action="order_process.php" method="post">
<div class="mb-3">
<label for="name" class="form-label">Full Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="mb-3">
<label for="address" class="form-label">Address</label>
<input type="text" class="form-control" id="address" name="address" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="phone" class="form-label">Phone</label>
<input type="tel" class="form-control" id="phone" name="phone" required>
</div>
<h4 class="mt-4">Order Summary</h4>
<ul class="list-group">
<?php foreach ($cart as $product_id => $quantity): ?>
<li class="list-group-item">
Product ID: <?php echo $product_id; ?>, Quantity: <?php echo $quantity; ?>
</li>
<?php endforeach; ?>
</ul>
<button type="submit" class="btn btn-primary mt-3">Proceed to Payment</button>
</form>
</div>
</body>
</html>