Prestashop-验证付款后更改订单状态 [英] Prestashop - Change order status when payment is validated
问题描述
验证付款后,订单状态将变为付款验证(法语为 Paiementaccepté)。我想在验证付款后设置其他状态,因此历史记录将显示以下内容:
When a payment is validated, the order status becomes "Payment validated" ("Paiement accepté" in french). I want to set another status when payment is validated, so the history would show the following :
Current status : My personnal status
History :
My personnal status
Payment validated
要这样做,我使用钩子actionOrderStatusPostUpdate。这是我的代码:
To do so, I use the hook actionOrderStatusPostUpdate. This is my code :
public function hookActionOrderStatusPostUpdate($aParams) {
$oOrder = new Order($aParams['id_order']);
if($aParams['newOrderStatus']->id == Configuration::get('PS_OS_PAYMENT')) {
$oOrder->setCurrentState(Configuration::get('XXXXXX_STATUS_WAITING'));
$oOrder->save();
}
}
已正确定义配置值。该代码有效,因为我看到状态已更改。但问题是,在更改为付款验证之前,它已更改。我不明白为什么。历史记录如下:
The Configuration values are correctly defined. This code works, because I see the status changed. But the thing is it changed BEFORE changing to "Payment validated". I don't understand why. The history looks like this :
Current status : Payment validated
History :
Payment validated
My personnal status
我该怎么做才能使我的个人身份显示为最后一个身份?
What should I do to make My personnal status appear as the last status ?
推荐答案
hookActionOrderStatusPostUpdate 挂钩调用由changeIdOrderState进行,但添加到order_history表是在changeIdOrderState调用后进行的如 https:// github .com / PrestaShop / PrestaShop / blob / 1.6.1.x / controllers / admin / AdminOrdersController.php#L521-L542
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
您宁愿绑定您的模块位于经典挂钩上,例如 hookActionObjectOrderHistoryAddAfter https://github.com/Prest aShop / PrestaShop / blob / 1.6.1.x / classes / ObjectModel.php#L535-L537
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
这篇关于Prestashop-验证付款后更改订单状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!