From 0c2d19c6ac7468d09e4b47c77d528d5b68d492a4 Mon Sep 17 00:00:00 2001 From: Sumit Panwar Date: Sat, 1 Feb 2025 10:25:09 +0530 Subject: [PATCH] Fixed: Emails regarding awaiting payment should not be sent to customers if the payment amount in the order is 0. --- classes/PaymentModule.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index f084284e3..85464fcaa 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -1006,7 +1006,11 @@ abstract class PaymentModuleCore extends Module $new_history = new OrderHistory(); $new_history->id_order = (int)$order->id; $new_history->changeIdOrderState((int)$id_order_state, $order, true); - if ($send_mails) { + + // Emails regarding awaiting payment should not be sent to customers if the payment amount in the order is 0. + $sendOrderStatusMail = (($id_order_state == Configuration::get('PS_OS_AWAITING_REMOTE_PAYMENT') || $id_order_state == Configuration::get('PS_OS_AWAITING_PAYMENT')) && $order->total_paid > 0) ? true : false; + + if ($send_mails && $sendOrderStatusMail) { $new_history->addWithemail(true, $extra_vars); } else { $new_history->add(true);