4

How would I remove billing (or shipping) address in Spree checkout routine? I'm using spree 1.3

Maoko
  • 41
  • 3

2 Answers2

7

You can remove the shipping address by removing the delivery step from your checkout_flow definition by putting this code inside your application at app/models/spree/order_decorator.rb:

Spree::Order.class_eval do
  checkout_flow do
    go_to_state :address
    go_to_state :payment, :if => lambda { |order| order.payment_required? }
    go_to_state :confirm, :if => lambda { |order| order.confirmation_required? }
    go_to_state :complete
    remove_transition :from => :delivery, :to => :confirm
  end
end

By not having the delivery step there, Spree won't ask for a delivery address or delivery information for an order.

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
  • 1
    I have already tried that, but I'm still getting validation errors (fields in delivery are required). Shipment fields has been removed from the address form thou. – Maoko Oct 22 '12 at 06:34
0

I have an alternate for this, if you are using spree-core

In your view/spree/checkout/edit file, there is a render statement which involves error_messages.html.erb = render :partial => 'spree/shared/error_messages', :locals => { :target => @order }

So now, you have to remove "ship" name from _error_messages.html.erb, then It will not show this kind of error.

Make some following changes in your spree/shared/_error_message file:

-target.errors.full_messages.each do |msg|
    -unless (msg.include?("Ship"))
        = msg

Remember, make changes also in error count accordingly using loop here. Currently I have no use of it, so made it comment

//= t(:errors_prohibited_this_record_from_being_saved, :count => target.errors.count)


I have also made comment on same question on github and stackoverflow- https://github.com/spree/spree/issues/2571#issuecomment-13769093

https://stackoverflow.com/questions/14891781/how-to-remove-the-shipping-address-validation-in-spree-checkout-process/14957973#comment20997203_14957973

Community
  • 1
  • 1
RohitPorwal
  • 1,045
  • 15
  • 23