Okay, i got it running perfectly, without touching the flow
First: Your order needs to decide if user can select shipping method (or our store does it)
Spree::Order.class_eval do
def needs_delivery?
#your logic goes here
return false
end
end
then we need the function that our order itself can select its shippingrate
Spree::Order.class_eval do
def select_default_shipping
#clone_billing_address #uncomment if user just types in one address
create_proposed_shipments #creates the shippings
shipments.first.update_amounts #uses the first shippings
update_totals #updates the order
end
end
next step is to hijack the checkout_controller technicall after address it will always go into the delivery step, where we have our logic inside before_delivery
Spree::CheckoutController.class_eval do
def before_delivery
if @order.needs_delivery?
#user needs to select shipping, default behaviour
@order.create_proposed_shipments
else
#we select the shipping for the user
@order.select_default_shipping
@order.next #go to next step
#default logic for finalizing unless he can't select payment_method
if @order.completed?
session[:order_id] = nil
flash.notice = Spree.t(:order_processed_successfully)
flash[:commerce_tracking] = "nothing special"
redirect_to completion_route
else
redirect_to checkout_state_path(@order.state)
end
end
end
end
Costs me lot of times, hope that saves somebody else time.