【问题标题】:How to remove steps from checkout in Sylius如何在 Sylius 中删除结帐步骤
【发布时间】:2019-03-28 15:40:36
【问题描述】:

我正在使用sylius/sylius 1.3.9 和symfony/framework-bundle 4.2.4。关于 doc 从结帐中删除状态,您必须替换 Sylius 核心包的整个配置。

我把我的配置放到src/Resources/SyliusCoreBundle/config/app/state_machine/sylius_order_checkout.yml:

winzou_state_machine:
    sylius_order_checkout:
        class: '%sylius.model.order.class%'
        property_path: checkoutState
        graph: sylius_order_checkout
        state_machine_class: '%sylius.state_machine.class%'
        states:
            cart: ~
            addressed: ~
            completed: ~
        transitions:
            address:
                from: [cart, addressed]
                to: addressed
            complete:
                from: [addressed]
                to: completed
        callbacks:
            after:
                sylius_process_cart:
                    on: [address]
                    do: ['@sylius.order_processing.order_processor', process]
                    args: [object]
                sylius_create_order:
                    on: [complete]
                    do: ['@sm.callback.cascade_transition', apply]
                    args: [object, event, create, sylius_order]
                sylius_save_checkout_completion_date:
                    on: [complete]
                    do: [object, completeCheckout]
                    args: [object]

之后我执行:

php bin/console cache:clear -e dev
[...]
php bin/console debug:winzou:state-machine sylius_order_checkout -e dev

+--------------------+
| Configured States: |
+--------------------+
| cart               |
| addressed          |
| shipping_selected  |
| shipping_skipped   |
| payment_skipped    |
| payment_selected   |
| completed          |
+--------------------+
[...]

什么都没有改变。当我关注文档中的link 时,它说:

在 Symfony 4.0 中移除了Bundle继承 [...]

那么 Symfony 4.2 是否仍然可以像文档建议的那样替换捆绑包的整个配置文件,或者这是 Sylius 1.3 中的回归,如果我没有做错任何事情,可能的解决方案是什么?

【问题讨论】:

    标签: symfony symfony4 sylius


    【解决方案1】:

    您可以尝试在config/packages 中创建state_machine 目录,将您的YAML 文件和configureContainer() 方法中的这一行添加到src/Kernel 中:

    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
        {
            ...
            $loader->load($confDir.'/state_machine/*'.self::CONFIG_EXTS, 'glob');
        }
    

    【讨论】:

    • 我在 config/state_machine/state_machine.yml 中添加了这个并删除了所有回调:之后:步骤、转换和状态,但结帐过程仍然正常进行。如果我把文件放在 config/packages/state_machine/ 它告诉我找不到它,在 config/state_machine/ 下没有这样的消息,但也没有效果。任何的想法?提前谢谢!
    猜你喜欢
    • 1970-01-01
    • 2015-06-11
    • 1970-01-01
    • 1970-01-01
    • 2019-08-18
    • 2020-05-27
    • 1970-01-01
    • 2012-08-26
    • 1970-01-01
    相关资源
    最近更新 更多