-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcancel_order.php
More file actions
37 lines (34 loc) · 1.28 KB
/
Copy pathcancel_order.php
File metadata and controls
37 lines (34 loc) · 1.28 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
<?php
require_once "conn.php";
session_start();
if (!isset($_SESSION["customer_id"])) {
echo "<script>alert('Please login');";
echo "window.location.href='index.php';</script>";
exit; // Stop further execution
} else {
if (isset($_GET['order_id'])) {
$oid = $_GET['order_id'];
// echo $oid;
$stmt = $conn->prepare("SELECT * FROM orders WHERE OID =?");
$stmt->bind_param("i", $oid);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$order_status = $row['order_status'];
}
}
if ($order_status === 'confirmed') {
$order_status = 'cancelled';
$delivery_status = 'Not deliverable';
$cancel_time = time();
$stmt1 = $conn->prepare("UPDATE orders SET order_status=?,delivery_status=?, delivery_time=? WHERE OID=?");
$stmt1->bind_param("sssi", $order_status, $delivery_status, $cancel_time, $oid);
$stmt1->execute();
require_once "cancel_order.html";
} else {
echo "<script>alert('order already cancelled');";
echo "window.history.back();</script>";
}
}
}