Spree remove billing address

烂漫一生 提交于 2019-12-23 12:48:08

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/12999588/spree-remove-billing-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!