I was able to make this code work, I got a couple of issues.
I want to replicate the same functionality when an order is changed to Payment Accepted in the BO, which does changes to a few tables.
When order status is changed to Payment Accepted in the BO, a new row is inserted to (at least) both ps_order_history and ps_order_invoice and the respective ps_orders entry is of course updated as well.
While experimenting with this code, I noticed a strange thing:
- If include the $history->save(); - the row is created into ps_order_history , but not in ps_order_invoice
- If I comment the $history->save(); - the row is created into ps_order_invoice, but not in ps_order_history
This seems super weird? Any ideas why this is happening? IMO both should be updated?
Also, are there any other tables that should be updated explicitly than the ones mentioned above?
I am also getting this error lot fo times:
Notice: Trying to get property 'precision' of non-object in /home/816694.cloudwaysapps.com/xxxx/public_html/classes/Context.php on line 498
Fatal error: Uncaught TypeError: Argument 1 passed to PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision::getPrecision() must be of the type int, null given, called in /home/816694.cloudwaysapps.com/xxxx/public_html/classes/Context.php on line 498 and defined in /home/816694.cloudwaysapps.com/xxxx/public_html/src/Core/Localization/CLDR/ComputingPrecision.php:41 Stack trace: #0 /home/816694.cloudwaysapps.com/xxxx/public_html/classes/Context.php(498): PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision->getPrecision() #1 /home/816694.cloudwaysapps.com/xxxx/public_html/classes/order/Order.php(1465): ContextCore->getComputingPrecision() #2 /home/816694.cloudwaysapps.com/xxxx/public_html/classes/order/Order.php(1353): OrderCore->setInvoiceDetails() #3 /home/816694.cloudwaysapps.com/xxxx/public_html/classes/order/OrderHistory.php(371): OrderCore->setInvoice() #4 /home/816694.cloudwaysapps.com/xxxx/public_html/yyyyyyyyy.php(13): OrderHistoryCore->changeIdOrderS in /home/816694.cloudwaysapps.com/xxxx/public_html/src/Core/Localization/CLDR/ComputingPrecision.php on line 41
Here's what I'm using (with 1.7.8.7):
<?php require(dirname(__FILE__).'/config/config.inc.php'); echo 'Includes done'.'<br/>'; echo 'Order ID:'.$_GET["oid"].'<br/>'; echo 'Order Status:'.$_GET["status"].'<br/>'; $objOrder = new Order($_GET["oid"]); $history = new OrderHistory(); $history->id_order = (int)$objOrder->id; $history->changeIdOrderState($_GET["status"], (int)($objOrder->id)); //order status 2 = Payment Accepted //$history->addWithemail(true); $history->save(); ?>