在shopware6中創建新訂單后嘗試觸發功能時我有點誤解,但沒有任何反應。我的語法可能是Shopware5,因為我是 SW6 的新手。這是我的代碼(僅用于測試):<?phpnamespace 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'); }}有什么地方可以找到與訂單相關的所有事件嗎?也許我使用的那個不正確。
2 回答

開心每一天1111
TA貢獻1836條經驗 獲得超13個贊
問題來自 services.xml 文件,您必須將其添加到您的訂戶服務中:
<tag name="kernel.event_listener" />
<tag name="kernel.event_subscriber" />

慕桂英3389331
TA貢獻2036條經驗 獲得超8個贊
public function __construct(EntityRepositoryInterface $orderRepository)
{
$this->orderRepository = $orderRepository;
}
public static function getSubscribedEvents(): array
{
return [
//CartEvents::CHECKOUT_ORDER_PLACED => 'onCheckoutOrderPlaced'
OrderEvents::ORDER_WRITTEN_EVENT => 'onOrderCheckout'
];
}
Shopware 和 PHP 對我來說是全新的,但上面的代碼正在為我觸發一個事件嘿,你能提供代碼來獲取訂單詳細信息嗎?
- 2 回答
- 0 關注
- 122 瀏覽
添加回答
舉報
0/150
提交
取消