-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
After upgrade from version 1.16.1 to latest version 1.23.0 each order shows duplicate state "Payment Accepted" and customer receive duplicate emails.
My prestashop version is 1.7.8.7
I found that root cause of issue has been added in version 1.16.5: "Bug fix: Fix payment in installments invoice for PrestaShop 1.7.x and higher."
This block code has been added and it generate an extra OrderHistory with an extra email
if (version_compare(_PS_VERSION_, '1.7', '>')) {
// Send email upon the update of the payment.
$order_history = new OrderHistory();
$order_history->id_order = (int) $order->id;
$order_history->id_order_state = $order->getCurrentState();
if (! $order_history->addWithemail(true)) {
$this->logger->logInfo("Failed to send email when updating payments for cart #{$cart->id}.");
}
// Delete double entry from history.
$result = Db::getInstance()->execute(
'DELETE FROM `' . _DB_PREFIX_ . 'order_history` WHERE `id_order` = ' . (int) $order->id . ' AND `id_order_state` = '
. (int) $order->getCurrentState() . ' ORDER BY `date_add` DESC LIMIT 1');
if (! $result) {
$this->logger->logWarning("An error occurred when deleting history for order #{$order->id}.");
}
}
When I remove this code, situation is back to normal
Indeed in current code, the order is update twice :
- at row 2193 by calling
validateOrderwhich calls$new_history->addWithemail(true, $extra_vars); - at row 2221 by calling
if (! $order_history->addWithemail(true)) {
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels