[03/04/2023] Modif du module OrderStatusNotify pour ajouter le lien de suivi (en attendant de corriger le pb MR)
This commit is contained in:
@@ -8,8 +8,10 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||||||
use Thelia\Core\Event\Order\OrderEvent;
|
use Thelia\Core\Event\Order\OrderEvent;
|
||||||
use Thelia\Core\Event\TheliaEvents;
|
use Thelia\Core\Event\TheliaEvents;
|
||||||
use Thelia\Mailer\MailerFactory;
|
use Thelia\Mailer\MailerFactory;
|
||||||
|
use Thelia\Model\OrderStatus;
|
||||||
use Thelia\Model\OrderStatusI18nQuery;
|
use Thelia\Model\OrderStatusI18nQuery;
|
||||||
use Thelia\Log\Tlog;
|
use Thelia\Log\Tlog;
|
||||||
|
use Thelia\Model\OrderStatusQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class OrderStatusListener
|
* Class OrderStatusListener
|
||||||
@@ -36,9 +38,32 @@ class OrderStatusListener implements EventSubscriberInterface
|
|||||||
{
|
{
|
||||||
$order = $event->getOrder();
|
$order = $event->getOrder();
|
||||||
$new_status_id = $event->getStatus();
|
$new_status_id = $event->getStatus();
|
||||||
|
$order_status_code = OrderStatusQuery::create()
|
||||||
|
->findOneById($new_status_id)
|
||||||
|
->getCode();
|
||||||
|
|
||||||
$is_order_status_to_notify = OrderStatusNotificationQuery::create()->findOneByOrderStatusId($new_status_id);
|
$is_order_status_to_notify = OrderStatusNotificationQuery::create()->findOneByOrderStatusId($new_status_id);
|
||||||
if (null !== $is_order_status_to_notify) {
|
if (null !== $is_order_status_to_notify) {
|
||||||
|
|
||||||
|
$delivery_module = $order->getModuleRelatedByDeliveryModuleId()->getCode();
|
||||||
|
if ($order_status_code === OrderStatus::CODE_SENT) {
|
||||||
|
switch ($delivery_module) {
|
||||||
|
case "MondialRelay":
|
||||||
|
$delivery_link = 'https://www.mondialrelay.fr/suivi-de-colis/' . $order->getDeliveryRef();
|
||||||
|
break;
|
||||||
|
case "Colissimo":
|
||||||
|
case "ColissimoWs":
|
||||||
|
$delivery_link = 'https://www.colissimo.fr/portail_colissimo/suivreResultat.do?parcelnumber=' . $order->getDeliveryRef();
|
||||||
|
break;
|
||||||
|
case "Chronopost":
|
||||||
|
case "ChronopostHomeDelivery":
|
||||||
|
$delivery_link = 'https://www.chronopost.fr/tracking-no-cms/suivi-page?listeNumerosLT=' . $order->getDeliveryRef();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$delivery_link = "No link";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$new_statut_label = OrderStatusI18nQuery::create()
|
$new_statut_label = OrderStatusI18nQuery::create()
|
||||||
->filterByLocale($order->getLang()->getLocale())
|
->filterByLocale($order->getLang()->getLocale())
|
||||||
->findOneById($new_status_id)
|
->findOneById($new_status_id)
|
||||||
@@ -51,6 +76,7 @@ class OrderStatusListener implements EventSubscriberInterface
|
|||||||
'order_id' => $order->getId(),
|
'order_id' => $order->getId(),
|
||||||
'order_ref' => $order->getRef(),
|
'order_ref' => $order->getRef(),
|
||||||
'new_status' => $new_statut_label,
|
'new_status' => $new_statut_label,
|
||||||
|
'delivery_link'=> $delivery_link
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
Tlog::getInstance()->debug("Order status change sent to customer " . $order->getCustomer()->getEmail());
|
Tlog::getInstance()->debug("Order status change sent to customer " . $order->getCustomer()->getEmail());
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ return [
|
|||||||
'Purpose of feature' => 'Veuillez sélectionner les statuts de commande pour lesquels vous souhaitez notifier le client : dès que la commande passera dans ce statut, un email sera envoyé au client.',
|
'Purpose of feature' => 'Veuillez sélectionner les statuts de commande pour lesquels vous souhaitez notifier le client : dès que la commande passera dans ce statut, un email sera envoyé au client.',
|
||||||
'Change on your order %ref on %store_name' => 'Evolution sur votre commande %ref sur le site %store_name',
|
'Change on your order %ref on %store_name' => 'Evolution sur votre commande %ref sur le site %store_name',
|
||||||
'Hello, your order has just changed to' => 'Bonjour, votre commande vient de passer à l\'état : ',
|
'Hello, your order has just changed to' => 'Bonjour, votre commande vient de passer à l\'état : ',
|
||||||
|
'Follow your order here:' => 'Suivez votre colis en cliquant ici : ',
|
||||||
|
'Delivery link' => '<a href="%link">%link</a>',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -74,6 +74,9 @@
|
|||||||
{intl l="Paid With:"} {loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}<br />
|
{intl l="Paid With:"} {loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}<br />
|
||||||
{intl l="Purchase Date:"} {format_date date=$CREATE_DATE output="datetime"}<br />
|
{intl l="Purchase Date:"} {format_date date=$CREATE_DATE output="datetime"}<br />
|
||||||
{intl l="Delivery method:"} {loop name="delivery-module" type="module" id=$DELIVERY_MODULE}{$TITLE}{/loop}<br />
|
{intl l="Delivery method:"} {loop name="delivery-module" type="module" id=$DELIVERY_MODULE}{$TITLE}{/loop}<br />
|
||||||
|
{if $IS_SENT}
|
||||||
|
{intl l="Follow your order here:" d="orderstatusnotify"} <strong>{intl l="Delivery link" d="orderstatusnotify" link={$delivery_link}}</strong><br />
|
||||||
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{hook name="email-html.order-notification.before-products" order=$order_id}
|
{hook name="email-html.order-notification.before-products" order=$order_id}
|
||||||
|
|||||||
Reference in New Issue
Block a user