local/modules/FairDelivery/Hook/MailHook.php line 11

  1. <?php
  2. namespace FairDelivery\Hook;
  3. use FairDelivery\Model\FairDeliveryQuery;
  4. use HookFetes\Model\AgendaFetesQuery;
  5. use Thelia\Core\Event\Hook\HookRenderEvent;
  6. use Thelia\Core\Hook\BaseHook;
  7. class MailHook extends BaseHook
  8. {
  9.     public function onEmailHtmlOrderConfirmationBeforProducts(HookRenderEvent $event){
  10.         $orderId $event->getArgument('order');
  11.         $currentFair FairDeliveryQuery::create()->findOneByOrderId(intval($orderId));
  12.         if(is_null($currentFair)) return;
  13.         $currentFairId $currentFair->getAgendaFetesId();
  14.         $fairTitle AgendaFetesQuery::create()->findOneByFetesId($currentFairId)->getTitle();
  15.         $html "<div>".$fairTitle."</div>";
  16.         $event->add($html);
  17.     }
  18.     public static function getSubscribedHooks():array
  19.     {
  20.         return [
  21.             "email-html.order-confirmation.before-products" => [
  22.                 [
  23.                     "type" => "email",
  24.                     "method" => "onEmailHtmlOrderConfirmationBeforProducts"
  25.                 ]               
  26.                 ]
  27.         ];
  28.     }
  29. }