From 56385183f0330e579be06b1c6a55411a2eb11e6d Mon Sep 17 00:00:00 2001 From: tomjas1997 Date: Thu, 12 Oct 2023 11:01:49 +0300 Subject: [PATCH] Added fixes --- saferpayofficial.php | 6 +++--- .../Verification/CanSendOrderConfirmationEmail.php | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index 1f61be00..321ae24f 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -523,7 +523,7 @@ public function hookActionEmailSendBefore($params) $canSendOrderConfirmationEmail = $this->getService(\Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail::class); if ($params['template'] === 'order_conf') { - return $canSendOrderConfirmationEmail->verify($order); + return $canSendOrderConfirmationEmail->verify($order, (int) $order->current_state); } if ($params['template'] === 'new_order') { @@ -560,13 +560,13 @@ public function hookActionOrderStatusUpdate($params = []) $saferPayAuthorizedStatus = (int) Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED); if ($orderStatus->id === $saferPayAuthorizedStatus && Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_SEND_NEW_ORDER_MAIL)) { - $mailService->sendNewOrderMail($order, $orderStatus->id); + $mailService->sendNewOrderMail($order, (int) $orderStatus->id); } /** @var \Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail $canSendOrderConfirmationEmail */ $canSendOrderConfirmationEmail = $this->getService(\Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail::class); - if ($canSendOrderConfirmationEmail->verify($order)) { + if ($canSendOrderConfirmationEmail->verify($order, (int) $orderStatus->id)) { $mailService->sendOrderConfMail($order, (int)$orderStatus->id); } } diff --git a/src/Core/Order/Verification/CanSendOrderConfirmationEmail.php b/src/Core/Order/Verification/CanSendOrderConfirmationEmail.php index 31d49c3a..11166f7b 100644 --- a/src/Core/Order/Verification/CanSendOrderConfirmationEmail.php +++ b/src/Core/Order/Verification/CanSendOrderConfirmationEmail.php @@ -27,30 +27,30 @@ class CanSendOrderConfirmationEmail { - public function verify(\Order $order) + public function verify(\Order $order, $orderStatusId) { if (!\Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_SEND_ORDER_CONFIRMATION)) { return false; } - if (!$this->isOrderStatusValid($order)) { + if (!$this->isOrderStatusValid($orderStatusId)) { return false; } return true; } - private function isOrderStatusValid(\Order $order): bool + private function isOrderStatusValid($orderStatusId) { - if ((int) \Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED) === (int) $order->current_state) { + if ((int) \Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED) === (int) $orderStatusId) { return true; } - if ((int) \Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_COMPLETED) === (int) $order->current_state) { + if ((int) \Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_COMPLETED) === (int) $orderStatusId) { return true; } - if ((int) \Configuration::get(SaferPayConfig::STATUS_PS_OS_OUTOFSTOCK_PAID) === (int) $order->current_state) { + if ((int) \Configuration::get(SaferPayConfig::STATUS_PS_OS_OUTOFSTOCK_PAID) === (int) $orderStatusId) { return true; }