custom/plugins/TdsOrlob/src/Subscriber/CheckoutOrderPlacedSubscriber.php line 49

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Tds\Orlob\Subscriber;
  3. use Shopware\Core\Checkout\Cart\Event\CheckoutOrderPlacedEvent;
  4. use Shopware\Core\System\SystemConfig\SystemConfigService;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. /**
  7.  * Class ProductPageSubscriber
  8.  *
  9.  * @package Tds\Campado\Subscriber
  10.  */
  11. class CheckoutOrderPlacedSubscriber implements EventSubscriberInterface
  12. {
  13.     private $systemConfigService;
  14.     /**
  15.      * ProductPageSubscriber constructor.
  16.      *
  17.      * @param SystemConfigService $systemConfigService
  18.      */
  19.     public function __construct(SystemConfigService $systemConfigService)
  20.     {
  21.         $this->systemConfigService $systemConfigService;
  22.     }
  23.     /**
  24.      * {@inheritDoc}
  25.      */
  26.     public static function getSubscribedEvents(): array
  27.     {
  28.         return [
  29.             CheckoutOrderPlacedEvent::class => 'onCheckoutOrderPlaced'
  30.         ];
  31.     }
  32.     /**
  33.      * @param CheckoutOrderPlacedEvent $event
  34.      *
  35.      */
  36.     public function onCheckoutOrderPlaced(CheckoutOrderPlacedEvent $event)
  37.     {
  38.         $additionalOrderMail = (string) $this->systemConfigService->get('TdsOrlob.config.additionalOrderMail');
  39.         if (!empty($additionalOrderMail)) {
  40.             $mailStruct $event->getMailStruct();
  41.             if ($mailStruct) {
  42.                 $mailStruct->setBcc($additionalOrderMail);
  43.                 $mailStruct->setCc($additionalOrderMail);
  44.             }
  45.         }
  46.     }
  47. }