Correction d'un bogue sur le module OrderStatusNotify
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace OrderStatusNotify\EventListeners;
|
||||
|
||||
use mysql_xdevapi\Exception;
|
||||
use OrderStatusNotify\Model\OrderStatusNotificationQuery;
|
||||
use OrderStatusNotify\OrderStatusNotify;
|
||||
use Symfony\Component\Debug\Exception\FatalErrorException;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
@@ -39,20 +41,30 @@ class OrderStatusListener implements EventSubscriberInterface
|
||||
|
||||
$is_order_status_to_notify = OrderStatusNotificationQuery::create()->findOneByOrderStatusId($new_status_id);
|
||||
if (null !== $is_order_status_to_notify) {
|
||||
$new_statut_label = OrderStatusI18nQuery::create()
|
||||
->filterByLocale($order->getLang()->getLocale())
|
||||
->findOneById($new_status_id)
|
||||
->getTitle();
|
||||
try {
|
||||
$new_statut_label = OrderStatusI18nQuery::create()
|
||||
->filterByLocale($order->getLang()->getLocale())
|
||||
->findOneById($new_status_id)
|
||||
->getTitle();
|
||||
}
|
||||
catch (\Throwable $e) {
|
||||
$new_statut_label = OrderStatusI18nQuery::create()
|
||||
->filterByLocale('fr_FR')
|
||||
->findOneById($new_status_id)
|
||||
->getTitle();
|
||||
}
|
||||
|
||||
$this->mailer->sendEmailToCustomer(
|
||||
OrderStatusNotify::MESSAGE_NAME,
|
||||
$order->getCustomer(),
|
||||
[
|
||||
'order_id' => $order->getId(),
|
||||
'order_ref' => $order->getRef(),
|
||||
'new_status' => $new_statut_label,
|
||||
]
|
||||
);
|
||||
if (null !== $new_statut_label) {
|
||||
$this->mailer->sendEmailToCustomer(
|
||||
OrderStatusNotify::MESSAGE_NAME,
|
||||
$order->getCustomer(),
|
||||
[
|
||||
'order_id' => $order->getId(),
|
||||
'order_ref' => $order->getRef(),
|
||||
'new_status' => $new_statut_label,
|
||||
]
|
||||
);
|
||||
}
|
||||
Tlog::getInstance()->debug("Order status change sent to customer " . $order->getCustomer()->getEmail());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user