-
Notifications
You must be signed in to change notification settings - Fork 18
/
payment.php
190 lines (176 loc) · 7.56 KB
/
payment.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
<?php
session_start();
// Check authentication
if (!isset($_SESSION['auth'])) {
$_SESSION['message'] = "Please login first";
header('Location: index.php');
exit();
}
// INCLUDE NECESSARY FILES
include('includes/header.php');
include('includes/orderbar.php');
include('functions/userFunctions.php');
// GET USER ID FROM SESSION
$userId = $_SESSION['user_id'];
// Reconnect to the database if necessary
if (mysqli_connect_errno()) {
include('config/dbconnect.php'); // Assuming dbconnect.php contains the connection code
}
$userDetails = getUserDetails($userId);
if ($userDetails) {
// Fetch order details from session
if (isset($_GET['id'])) {
$order_id = $_GET['id'];
// Call getOrderDetails to fetch order details
$orderDetails = getOrderDetails($con, $order_id);
$orderStatus = $orderDetails['orderStatus'];
$order_at = $orderDetails['order_at'];
$subtotal = $orderDetails['orderSubTotal'];
$additional_fee = $orderDetails['orderAddFee'];
$grandtotal = $orderDetails['orderGrandTotal'];
// Check if the status is available
if ($orderStatus !== "Not available") {
// Display the order status
echo "Order Status: " . $orderStatus;
} else {
// Display a message if the status is not available
echo "Order status is not available.";
}
?>
<!-- HTML Section for Payment Details -->
<section class="p-5 p-md-5 mt-4 text-sm-start" style="font-family: 'Poppins'">
<div class="container">
<div class="row">
<div class="col-md-10">
<h1 style="font-family: 'Suez One', sans-serif; color: #013D67;"><i class="fas fa-coins"></i> Payment Details</h1>
</div>
</div>
<div class="row">
<div class="col-md-3 text-center">
<!-- Delivery Details Card -->
<div class="card shadow-sm rounded-3 p-2 mt-4">
<h4>Order ID #<?= $order_id ?></h4>
<h6><?= formatDate($order_at) ?></h6>
</div>
<div class="card shadow-sm rounded-3 p-3 mt-2">
<h4>Order Status</h4>
<div class="p-1">
<h6><?= $orderStatus ?></h6>
</div>
</div>
<div class="card shadow-sm rounded-3 p-3 mt-2">
<h5>Delivery Details</h5>
<div class="p-1">
<h6>Customer Name: <br><?= $userDetails['name'] ?></h6>
</div>
<div class="p-1">
<h6>Contact Number: <br><?= $userDetails['phone'] ?></h6>
</div>
<div class="p-1">
<h6>Address: <br><?= $userDetails['address'] ?></h6>
</div>
</div>
</div>
<div class="col-md-9">
<!-- Order Summary Card -->
<div class="card shadow-sm rounded-3 p-3 mt-4 text-center">
<div class="row align-items-center">
<div class="col-6 col-md-2">
<h5>Quantity</h5>
</div>
<div class="col-6 col-md-4">
<h5>Items</h5>
</div>
<div class="col-md-3 d-none d-md-block">
<h5>Price</h5>
</div>
<div class="col-md-3 d-none d-md-block">
<h5>Total</h5>
</div>
</div>
</div>
<!-- Cart Items -->
<?php
$cartItems = getProductsByOrderId('order_items', $order_id);
foreach ($cartItems as $cartItem) {
// Check if product exists
if (!isset($cartItem['product_id'])) {
?>
<div class="card shadow-sm rounded-3 p-3 mt-2 text-center" style="font-family: 'Poppins'">
<span>Product not found</span>
</div>
<?php
continue; // Skip this iteration and proceed to the next item
}
$itemTotal = $cartItem['quantity'] * $cartItem['price'];
?>
<div class="card shadow-sm rounded-3 p-3 mt-2 text-center">
<div class="row align-items-center">
<div class="col-6 col-md-2">
<h5><?= $cartItem['quantity'] ?></h5>
</div>
<div class="col-6 col-md-2">
<img src="uploads/<?= $cartItem['product_image'] ?>" width="80px" alt="<?= $cartItem['product_name'] ?>" class="rounded-3">
</div>
<div class="col-md-2 d-none d-md-block">
<h5><?= $cartItem['product_name'] ?></h5>
</div>
<div class="col-md-3 d-none d-md-block">
<h5><?= $cartItem['price'] ?></h5>
</div>
<div class="col-md-3 d-none d-md-block">
<h5><span style="font-family: 'Poppins', sans-serif;">₱<?= $itemTotal ?>.00</span></h5>
</div>
</div>
</div>
<?php } ?>
<div class="card shadow-sm rounded-3 p-3 mt-2">
<h5>Order Summary</h5>
<!-- Display subtotal, delivery fee, and grand total -->
<div class="row align-items-center justify-content-between">
<div class="col-6 col-md-6 text-start">
<h5>Subtotal:</h5>
</div>
<div class="col-6 col-md-6 text-end">
<h5><span style="font-family: 'Poppins', sans-serif;">₱<?= $subtotal ?>.00</span></h5>
</div>
</div>
<div class="row align-items-center justify-content-between">
<div class="col-6 col-md-6 text-start">
<h5>Additional Fee:</h5>
</div>
<div class="col-6 col-md-6 text-end">
<h5><span style="font-family: 'Poppins', sans-serif;">₱<?= $additional_fee ?>.00</span></h5>
</div>
</div>
<div class="row align-items-center justify-content-between">
<div class="col-6 col-md-6 text-start">
<h5>Grand Total:</h5>
</div>
<div class="col-6 col-md-6 text-end">
<h5><span style="font-family: 'Poppins', sans-serif;">₱<?= $grandtotal ?>.00</span></h5>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<?php
} else {
?>
<div class="card rounded-3 p-3 mt-3 text-center" style="font-family: 'Poppins'; border:none;">
<span>No order details found.</span>
</div>
<?php
}
} else {
?>
<div class="card rounded-3 p-3 mt-3 text-center" style="font-family: 'Poppins'; border:none;">
<span>No user details found.</span>
</div>
<?php
}
// INCLUDE FOOTER
include('includes/footer.php');
?>