Created
September 13, 2015 18:25
-
-
Save fiftin/ca7d75bf53e118810c4a to your computer and use it in GitHub Desktop.
Spree Commerce: Skip delivery checkout step
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::CheckoutController.class_eval do | |
def before_delivery | |
@order.next | |
redirect_to checkout_state_path(@order.state) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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