[英]Is there an order state change event in Shopware 6?
Shopware 6 中的訂單具有以下狀態:
<?php declare(strict_types=1);
namespace Shopware\Core\Checkout\Order;
final class OrderStates
{
public const STATE_MACHINE = 'order.state';
public const STATE_OPEN = 'open';
public const STATE_IN_PROGRESS = 'in_progress';
public const STATE_COMPLETED = 'completed';
public const STATE_CANCELLED = 'cancelled';
}
是否可以訂閱 state 更改? 是否有 state 更改事件或者這些狀態可以用作事件? 如果是,如何獲得更改后的 state 名稱?
事件在StateMachineRegistry::transition中調度。 正如您在StateMachineStateChangeEvent中看到的那樣,事件名稱是根據已更改的 state 生成的,例如state_machine.order_transaction.state_changed
這些事件甚至在Shopware 本身中用於調度特殊的OrderStateMachineStateChangeEvent 。 這些事件的名稱在此處生成,例如state_enter.order_transaction.state.paid
您可以在此處找到所有訂單事件: https://github.com/shopware/platform/blob/6.2/src/Core/Checkout/Order/OrderEvents.php
ORDER_TRANSACTION_STATE_* 或 ORDER_WRITTEN_EVENT
應該是go的方式。
在此之后,您可以獲得 EntityEvent 的有效負載: https://github.com/shopware/platform/blob/6.2/src/Core/Framework/DataAbstractionLayer/Event/EntityWrittenEvent.php -> getPayloads()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.