mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Spree does not call after_<order.state> methods any more as of https://github.com/spree/spree/pull/2557, so our #after_complete method is never triggered and thus the order never reset. This makes the condition: ```ruby if current_order.andand.distributor == @order.distributor ``` in app/views/spree/orders/form/_update_buttons.html.haml return false and as a result the "Back To Cart" button is not shown. This commit resets the order (emptying the session[:order_id] and creating a new order, aka. cart) right from the CheckoutController#update rather than relying on infernal callbacks (of what the Spree core team itself was unhappy about since long ago https://github.com/spree/spree/issues/2488). There is the first place where we know the order has been successfully completed.