Correction d'un bogue sur module OrderStatusNotify

This commit is contained in:
2020-11-17 11:55:28 +01:00
parent d0944147e5
commit 2e80674fd2

View File

@@ -39,20 +39,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());
}
}