Click here to Skip to main content
15,885,979 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
OpenCart 3.0 does not support order cancellation from customer side so
I am trying to make one php page for canceling order by customer side
i just add one button on order info page for order cancellation and I am just trying to update order_status_id so it will be show me accordingly
I am trying this code without modifying core file of OpenCart 3.0
But my code is not working

What I have tried:

<pre><?php
include 'config.php';
// Create connection
$conn = new mysqli(DB_HOSTNAME,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";

$sql = "UPDATE order SET order_status_id =8 WHERE customer_id= 2 ";

if ($conn->query($sql) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $conn->error;
}

$conn->close();

?>

<script>alert("The order was canceled!");
window.location.replace('/')
</script>


it show error
Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order SET order_status_id =8 WHERE customer_id= 2' at line 1 



If anybody is expert in OpenCart 3.0 MVC Programming then plz help me

Thanks
Posted
Comments
Mohibur Rashid 31-Mar-19 19:36pm    
order is a keyword in sql, to use properly try using tilted quote, on keyboard shift+1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900