Prestashop - Change order status when payment is validated

醉酒当歌 提交于 2019-12-04 09:48:33

hookActionOrderStatusPostUpdate hook call is made by changeIdOrderState but the add to order_history table is made after the call of changeIdOrderState like in https://github.com/PrestaShop/PrestaShop/blob/1.6.1.x/controllers/admin/AdminOrdersController.php#L521-L542

You rather need to bind your module on a classic hook like hookActionObjectOrderHistoryAddAfter https://github.com/PrestaShop/PrestaShop/blob/1.6.1.x/classes/ObjectModel.php#L535-L537

public function hookActionObjectOrderHistoryAddAfter($params) {
$orderHistory = $params['object'];

if($orderHistory->id_order_state == Configuration::get('PS_OS_PAYMENT')) {
    $oOrder->setCurrentState(Configuration::get('XXXXXX_STATUS_WAITING'));
    $oOrder->save();
}

Best Regards

I think it'll work on other hook: actionOrderStatusUpdate

I think this is what you should use to change order status after payment validate those hooks are called when status changing or status changed.

$history = new OrderHistory();
$history->id_order = (int)$id_order;
$history->changeIdOrderState($status_id, (int)$id_order);
$history->addWithemail();
$history->save();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!