Shopware6 : Which event to subscribe when an order is paid?

I would like to know which event should I use if I want to trigger a function when an order is PAID after its creation by the cusstomer.

I have already tried with this one : state_enter.order_transaction.state.paid => ‘onOrderCheckout’.

Unfortunately, it gave an error :"
Warning: Use of undefined constant state_enter – assumed ‘state_enter’ (this will throw an Error in
a future version of PHP)*".

Here is my subscriber :


namespace EmakersTransmissionPluginSubscriber;

use SymfonyComponentEventDispatcherEventSubscriberInterface;
use ShopwareCoreFrameworkDataAbstractionLayerEventEntityLoadedEvent;
use SymfonyComponentHttpKernelEventExceptionEvent;
use ShopwareCoreCheckoutOrderOrderEntity;
use ShopwareCoreCheckoutOrderOrderEvents;
use ShopwareCoreSystemStateMachineEvent;
use ShopwareCoreFrameworkEventEventDataEntityType;
use ShopwareCoreSystemSystemConfigSystemConfigService;
use SymfonyComponentHttpKernelKernelEvents;
use SymfonyComponentDependencyInjectionContainerInterface;
use ShopwareCoreFrameworkDataAbstractionLayerSearchCriteria;
use ShopwareCoreFrameworkDataAbstractionLayerSearchFilterEqualsFilter;
use EmakersTransmissionPluginServicesShopwareConnectService;


class OrderSubscriber implements EventSubscriberInterface
{
    /**
     * @ContainerInterface $container
     */
    private $container;


     /**
     * @var datetime
     */
     private $now;


     public function __construct(ContainerInterface $container) {
                $this->container = $container;
                $this->now = date('Y-m-d H:i:s');
     }

    public static function getSubscribedEvents(): array
    {
        return [
                'state_enter.order_transaction.state.paid'   => 'onOrderCheckout',
        ];
    }
        public function orOrderCheckout($event)
        {
                var_dump($event);
                die('here we are');
        }
}

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *