简体   繁体   中英

How to remove steps from checkout in Sylius

I'm using sylius/sylius 1.3.9 with symfony/framework-bundle 4.2.4. Regarding the doc to remove states from checkout you have to replace the whole configuration of the Sylius core bundle.

I put my configuration into 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]

After that I execute:

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          |
+--------------------+
[...]

Nothing changed. When I follow the link in the doc it says:

Bundle inheritance was removed in Symfony 4.0 [...]

So is it still possible with Symfony 4.2 to replace a whole configuration file of a bundle like suggested by the docs or is this a regression in Sylius 1.3 and what would be a possible solution if I did nothing wrong?

You can try to create state_machine directory in config/packages , put your YAML file and add this line in configureContainer() method into src/Kernel:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM