<?php declare(strict_types=1);
namespace Tds\Orlob\Subscriber;
use Shopware\Core\Checkout\Cart\Event\CheckoutOrderPlacedEvent;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class ProductPageSubscriber
*
* @package Tds\Campado\Subscriber
*/
class CheckoutOrderPlacedSubscriber implements EventSubscriberInterface
{
private $systemConfigService;
/**
* ProductPageSubscriber constructor.
*
* @param SystemConfigService $systemConfigService
*/
public function __construct(SystemConfigService $systemConfigService)
{
$this->systemConfigService = $systemConfigService;
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents(): array
{
return [
CheckoutOrderPlacedEvent::class => 'onCheckoutOrderPlaced'
];
}
/**
* @param CheckoutOrderPlacedEvent $event
*
*/
public function onCheckoutOrderPlaced(CheckoutOrderPlacedEvent $event)
{
$additionalOrderMail = (string) $this->systemConfigService->get('TdsOrlob.config.additionalOrderMail');
if (!empty($additionalOrderMail)) {
$mailStruct = $event->getMailStruct();
if ($mailStruct) {
$mailStruct->setBcc($additionalOrderMail);
$mailStruct->setCc($additionalOrderMail);
}
}
}
}