Created
December 21, 2015 12:29
-
-
Save 1990prashant/978ecd264530d3cd5057 to your computer and use it in GitHub Desktop.
Skip delivery step but add default shipping for order in spree. Add the following methods in your order_decorator and checkout_controller_decorator
This file contains hidden or 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
def before_delivery | |
if @order.needs_delivery? | |
return if params[:order].present? | |
packages = @order.shipments.map(&:to_package) | |
@differentiator = Spree::Stock::Differentiator.new(@order, packages) | |
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 |
This file contains hidden or 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
def needs_delivery? | |
return false | |
end | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment