Imane Abi Posted January 23 Share Posted January 23 Hi, I’m using Prestashop 8.1.7 and I’ve developed a module to change the order status after payment is accepted. While the status is correctly updated in the ps_order_history table, it doesn’t seem to update in the ps_orders table (specifically the current_state column). Here’s the code I’m working with: public function hookActionObjectOrderHistoryAddAfter($params) { $orderHistory = $params['object']; $id_order = $orderHistory->id_order; $order = new Order($id_order); $cart = new Cart($order->id_cart); $products = $cart->getProducts(); if ($order->current_state == 2) { // Add status Payment Accepted ALN if ($carrier == 1799 || $carrier == 1885) { $this->changeOrderStatus($order, 62); } } ... } private function changeOrderStatus($order, $newStatusId) { $history = new OrderHistory(); $history->id_order = $order->id; $history->id_employee = 34; $history->changeIdOrderState($newStatusId, $order); $history->add(); } Example: SELECT id_order_state FROM `ps_order_history` WHERE id_order=10809 ORDER BY `id_order_history` DESC LIMIT 1; -- Result: 62 SELECT current_state FROM `ps_orders` WHERE id_order=10809; -- Result: 2 The status in the ps_order_history table is updated correctly to 62, but the current_state in the ps_orders table remains at 2. Do you have any suggestions for how to update the current_state field in the ps_orders table as well when the order status changes? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now