Shopware6下单触发功能

在shopware6中创建新订单后尝试触发功能时我有点误解,但没有任何反应。


我的语法可能是Shopware5,因为我是 SW6 的新手。


这是我的代码(仅用于测试):


<?php


namespace Emakers\TransmissionPlugin\Subscriber;


use Enlight_Hook_HookArgs;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

use Symfony\Component\HttpKernel\KernelEvents;


class OrderSubscriber implements EventSubscriberInterface

{

    public static function getSubscribedEvents()

    {

        // return the subscribed events, their methods and priorities

        return [

            KernelEvents::EXCEPTION => [

                ['OrderEvents::ORDER_WRITTEN_EVENT::RESPONSE' => 'onOrderCheckout'],

            ],

        ];

    }


    public function onOrderCheckout(Enlight_Hook_HookArgs $args): void

    {

        die('TEST OK');

    }

}

有什么地方可以找到与订单相关的所有事件吗?也许我使用的那个不正确。


尚方宝剑之说
浏览 63回答 2
2回答

开心每一天1111

问题来自 services.xml 文件,您必须将其添加到您的订户服务中:<tag name="kernel.event_listener" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<tag name="kernel.event_subscriber" />

慕桂英3389331

public function __construct(EntityRepositoryInterface $orderRepository){&nbsp; &nbsp; $this->orderRepository = $orderRepository;}public static function getSubscribedEvents(): array{&nbsp; &nbsp; return [&nbsp; &nbsp; &nbsp; &nbsp; //CartEvents::CHECKOUT_ORDER_PLACED => 'onCheckoutOrderPlaced'&nbsp; &nbsp; &nbsp; &nbsp; OrderEvents::ORDER_WRITTEN_EVENT => 'onOrderCheckout'&nbsp; &nbsp; ];}Shopware 和 PHP 对我来说是全新的,但上面的代码正在为我触发一个事件嘿,你能提供代码来获取订单详细信息吗?
打开App,查看更多内容
随时随地看视频慕课网APP