<?php declare(strict_types = 1);
namespace GrimmTheme\Storefront\Subscriber;
use Shopware\Core\Checkout\Order\Event\OrderPaymentMethodChangedCriteriaEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class OrderPaymentMethodChangedSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
OrderPaymentMethodChangedCriteriaEvent::class => 'onPaymentMethodChanged'
];
}
// SD-5184 - in order for the normal Bestellbestätigung to send here, add all info that is available with order.placed event
public function onPaymentMethodChanged(OrderPaymentMethodChangedCriteriaEvent $event)
{
$criteria = $event->getCriteria();
$criteria
->addAssociation('orderCustomer.customer')
->addAssociation('orderCustomer.salutation')
->addAssociation('deliveries.shippingMethod')
->addAssociation('deliveries.shippingOrderAddress.country')
->addAssociation('transactions.paymentMethod')
->addAssociation('lineItems.cover')
->addAssociation('currency')
->addAssociation('addresses.country');
}
}