首页 > 解决方案 > 如何在 Pimcore 的 CoreShop 中收听“确认”状态机?

问题描述

根据文档 https://docs.coreshop.org/2.1.0/Development/State_Machine/Available_Workflows.html https://docs.coreshop.org/2.1.0/Development/State_Machine/Create_Callbacks.html ,这个配置应该在刚刚创建订单时监听事件(用户在提交数据和发货后单击“购买”按钮)。

### CoreShop Workflow callbacks in config.yml of MyBundle
core_shop_workflow:
    state_machine:
        coreshop_order:
            callbacks:
                after:
                    preAuthorizeGuradoVoucher:
                        on: [ 'confirm' ]
                        do: [ '@MyBundle\EventListener\GuradoVoucherListener', 'preAuthorize' ]
                        # in this context, "object" is the order item
                        args: [ 'object' ]
                        priority: -10 
                    newOrder:
                        on: [ 'new' ]
                        do: [ '@MyBundle\EventListener\GuradoVoucherListener', 'new' ]
                        # in this context, "object" is the order item
                        args: [ 'object' ]
                        priority: -10 
                    requestPayment:
                        on: [ 'request_payment' ]
                        do: [ '@MyBundle\EventListener\GuradoVoucherListener', 'requestPayment' ]
                        # in this context, "object" is the order item
                        args: [ 'object' ]
                        priority: -10 
        coreshop_order_payment:
            callbacks:
                after:
                    sellGuradoVoucher:
                        on: [ 'paid' ]
                        do: [ '@MyBundle\EventListener\GuradoVoucherListener', 'sellVoucher' ]
                        # in this context, "object" is the order item
                        args: [ 'object' ]
                        priority: -10 
                    redeemGuradoVoucher:
                        on: [ 'paid' ]
                        do: [ '@MyBundle\EventListener\GuradoVoucherListener', 'redeem' ]
                        # in this context, "object" is the order item
                        args: [ 'object' ]
                        priority: -10 
                    refundGuradoVoucher:
                        on: [ 'refunded' ]
                        do: [ '@MyBundle\EventListener\GuradoVoucherListener', 'refund' ]
                        # in this context, "object" is the order item
                        args: [ 'object' ]
                        priority: -10 

但事实上,当付款完成时,第一个事件在 /finish-order 页面上被调用。

如何配置在提交购物车和刚刚创建订单时捕获事件?

标签: configurationyamlevent-listenerpimcorecoreshop

解决方案


推荐阅读