<?php declare(strict_types=1);
namespace LoyxxSeminar\Subscriber;
use LoyxxSeminar\Core\Checkout\Cart\Participant\ParticipantTransformer;
use Shopware\Core\Checkout\Cart\Order\CartConvertedEvent;
use Shopware\Core\Framework\Event\BeforeSendResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CartConvertedEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
CartConvertedEvent::class => 'convertParticipants'
];
}
public function convertParticipants(CartConvertedEvent $event)
{
$cart = $event->getCart();
$convertedCart = $event->getConvertedCart();
$convertedCartWithParticipants = ParticipantTransformer::transformParticipantInCart($cart, $convertedCart);
$event->setConvertedCart($convertedCartWithParticipants);
}
}