local/modules/TheliaGiftCard/Hook/HookFrontManager.php line 29

Open in your IDE?
  1. <?php
  2. /*************************************************************************************/
  3. /*      Copyright (c) BERTRAND TOURLONIAS                                            */
  4. /*      email : btourlonias@openstudio.fr                                            */
  5. /*************************************************************************************/
  6. namespace TheliaGiftCard\Hook;
  7. use Thelia\Core\Event\Hook\HookRenderEvent;
  8. use Thelia\Core\Hook\BaseHook;
  9. use Thelia\Model\CategoryQuery;
  10. use Thelia\Tools\URL;
  11. use TheliaGiftCard\TheliaGiftCard;
  12. class HookFrontManager extends BaseHook
  13. {
  14.     public function onAccountBottom(HookRenderEvent $event)
  15.     {
  16.         $category CategoryQuery::create()->findPk(TheliaGiftCard::getGiftCardCategoryId());
  17.         if ($category) {
  18.             $urlToBuyGiftCard URL::getInstance()->absoluteUrl($category->getRewrittenUrl($this->getSession()->getLang()->getLocale()));
  19.             $event->add(
  20.                 $this->render("account-gift-card.html", ['urlToBuyGiftCard' => $urlToBuyGiftCard])
  21.             );
  22.         }
  23.     }
  24.     public function onOrderInvoiceBottom(HookRenderEvent $event)
  25.     {
  26.         $event->add(
  27.             $this->render("order-invoice-gift-card.html", ['total_without_giftcard' => $event->getArgument('total')])
  28.         );
  29.     }
  30.     public function onProductAdditional(HookRenderEvent $event)
  31.     {
  32.         $productId $event->getArgument('product');
  33.         $tabProductGiftCard TheliaGiftCard::getGiftCardProductList();
  34.         if (in_array($productId$tabProductGiftCard)) {
  35.             $event->add(
  36.                 $this->render("product-additional-gift-card.html", ['product_id' => $productId])
  37.             );
  38.         }
  39.     }
  40. }