shopware - 如何在 shopware6 中创建的订单上将订单状态从打开更改为报价?

标签 shopware

我正在为报价请求开发一个插件,我正在按照订单方法创建报价请求,我需要在创建订单时将订单状态从打开更改为报价,我尝试更改 stateId 但它没有用。后台的订单状态没有变成定制的。

<?php declare(strict_types=1);

namespace RequestanOffer\Subscriber;

use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Storefront\Page\Checkout\Cart\CheckoutCartPageLoadedEvent;
use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
use Shopware\Core\Checkout\Order\OrderEvents;

use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates;
use Shopware\Core\Checkout\Order\OrderStates;

use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenEvent;

use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;


class Subscriber implements EventSubscriberInterface
{
    public const STATE_MACHINE = 'order.state';
    private $orderRepository;
    private $stateMachineStateRepository;
    private CONST ORDER_OPEN = 'D6A9628852A141B9957FFB1A48EE9551';
    private CONST QUOTE_OPEN = '1FEA95C739834229996CEE2D8BEBFDC0';
    public function __construct(
        EntityRepositoryInterface $orderRepository,
        EntityRepositoryInterface $stateMachineRepository
    )
    {
        $this->orderRepository = $orderRepository;
        $this->stateMachineRepository = $stateMachineRepository;
    }


    public static function getSubscribedEvents(): array
    {
        return [
            ProductPageLoadedEvent::class => 'onProductPageLoaded',
            CheckoutCartPageLoadedEvent::class  => 'onCheckoutPageLoaded',
            CheckoutConfirmPageLoadedEvent::class => 'onCheckoutConfirmPageLoaded',
            OrderEvents::ORDER_WRITTEN_EVENT     => 'onQuoteOrder'
        ];
    }


    public function onQuoteOrder(EntityWrittenEvent $stateId, $event) {



           $stateId = $payloads[0]['stateId'] = $this::QUOTE_OPEN;
        $criteria = new Criteria();
        $criteria->addFilter(
            new EqualsFilter('stateId', $stateId)

        );

               var_dump($payloads[0]['stateId']);
               die('dump');
        }  
}

最佳答案

我通过添加 Core/StateMachineTransitionActions.php 解决了这个问题在我的插件中使用额外的 StateMachineTransitionActions 类。

public const ACTION_CANCEL = 'cancel';
public const ACTION_COMPLETE = 'complete';
public const ACTION_DO_PAY = 'do_pay';
public const ACTION_FAIL = 'fail';
public const ACTION_PAID = 'paid';
public const ACTION_PAID_PARTIALLY = 'paid_partially';
public const ACTION_PROCESS = 'process';
public const ACTION_REFUND = 'refund';
public const ACTION_REFUND_PARTIALLY = 'refund_partially';
public const ACTION_REMIND = 'remind';
public const ACTION_REOPEN = 'reopen';
public const ACTION_RETOUR = 'retour';
public const ACTION_RETOUR_PARTIALLY = 'retour_partially';
public const ACTION_SHIP = 'ship';
public const ACTION_SHIP_PARTIALLY = 'ship_partially';
public const ACTION_AUTHORIZE = 'authorize';
public const ACTION_CHARGEBACK = 'chargeback';
public const ACTION_ACCEPTQUOTE = 'accept_quote';
public const ACTION_ASKQUOTE = 'ask_quote';
public const ACTION_QUOTATIONREQUEST = 'quotation_request';
public const ACTION_QUOTATIONOFFER = 'quotation_offer';

关于shopware - 如何在 shopware6 中创建的订单上将订单状态从打开更改为报价?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69088973/

相关文章:

shopware - Shopware 6.5 下消息队列延迟不可用?

docker - ddev:从另一个容器调用Web容器的某个端口的端点

javascript - 无法通过 Shopware 6 中的 XmlHttpRequest 请求 PageController

shopware - 如何在现有安装中安装 Shopware 演示数据?

php - 如何访问Shopware中的数据库层?

javascript - 在 shopware 4.2.3 中编辑 HTMl 元素时。它给出 js 错误,我无法编辑

shopware - 如何访问 Shopware 6 中的自定义 cms 元素配置值?

php - 商店软件 6 : Unable to save an associate field (media) in the new custom plugin

shopware - 在电子邮件附件中使用 PDF mediaId

symfony - 商店用品 6 : Get PHP data in own custom admin module