bluco Posted March 29, 2022 Share Posted March 29, 2022 Hello, When we change the status in our prestashop manually from "Pago aceptado" (payment accepted) to "Enviado" (Shipped) everything works properly (See the picture attached: 1_change_status.png But when We do it via code it duplicates transactions entries. Please, find attached picture 2 (correct example manually) and picture 3 (incorrect example via code). This is our test code: $id_orderaux = 538; $order = new Order($id_orderaux); $id_order_state = '4'; $id_employee = '2'; $order->setCurrentState($id_order_state, $id_employee); Please, find also attached an screenshot of an order before changing status to Shipped (4_example_order_in_accepted_payment_status). Data about our system: Prestashop version: 1.7.7.5 MySQL: 10.0.38-MariaDB-0+deb8u1 PHP: 7.3.20 Thank you very much Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted March 29, 2022 Share Posted March 29, 2022 Hello, Something like this $order = new Order((int) $id_order); $history = new OrderHistory(); $history->id_order = (int) $order->id; if ($order->current_state != (int) $id_order_status) { $history->changeIdOrderState((int) $id_order_status, $order, true); $history->addWithemail(true); } Thank you 1 Link to comment Share on other sites More sharing options...
bluco Posted March 29, 2022 Author Share Posted March 29, 2022 Hello Nishith, Thanks for you quick answer. I'm afraid it didn't work properly. I've runned the following code: <?php define('DEBUG', true); ini_set('display_errors','on'); require '../vendor/autoload.php'; require '../config/config.inc.php'; $id_order = 557; $id_order_status = '4'; $id_employee = '2'; $order = new Order((int) $id_order); $history = new OrderHistory(); $history->id_order = (int) $order->id; if ($order->current_state != (int) $id_order_status) { $history->changeIdOrderState((int) $id_order_status, $order, true); $history->addWithemail(true); } ?> It changed the status to "Enviado" (Shipped) but it didn't created a history of the change and it didn't created the slip. Please, find attached an screnshoot of the result. Here you can find an order changed the status manually. Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted March 30, 2022 Share Posted March 30, 2022 Hello, Created slip or invoice depending on your status setting. Please read this https://doc.prestashop.com/display/PS17/Statuses Thank you 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