Sylius / AdminOrderCreationPlugin

Create orders in Sylius as an Administrator
MIT License
55 stars 50 forks source link

Check select shipping state should be applied #169

Open markjan opened 3 years ago

markjan commented 3 years ago

When creating an order using this plugin for a ProductVariant with shippingRequired = false I get an exception SMException in \Sylius\AdminOrderCreationPlugin\EventListener\OrderCreationListener::completeOrderBeforeCreation because the 'select_shipping' state can not be applied.

I suggest checking that state can be applied first as is done for the payment in the lines below:

if($stateMachine->can(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING)) {
   $stateMachine->apply(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING);
}

I can send you a path for the class and spec if you want.