Skip to content

Instantly share code, notes, and snippets.

@fiftin
Created September 13, 2015 18:25
Show Gist options
  • Save fiftin/ca7d75bf53e118810c4a to your computer and use it in GitHub Desktop.
Save fiftin/ca7d75bf53e118810c4a to your computer and use it in GitHub Desktop.
Spree Commerce: Skip delivery checkout step
Spree::CheckoutController.class_eval do
def before_delivery
@order.next
redirect_to checkout_state_path(@order.state)
end
end
Spree::Order.class_eval do
state_machine do
after_transition :to => :delivery do |order|
if order.shipments.all? { |shipment| shipment.shipping_rates.count == 1 }
order.shipments.each do |shipment|
shipment.selected_shipping_rate_id = shipment.shipping_rates.first.id
end
order.next
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment