Spree Checkout - Remove Step

走远了吗. 提交于 2019-12-04 13:47:27

OK, so I have finally found it -
Spree have released a new version #1.2.0 with a major fix for this exact problem.

Spree 1.2.0 Release Notes

The checkout process has always been hard to customize within Spree, and that has generated complaints in the past. We are pleased to report in the 1.2 release of Spree that this has been substaintially easier...

So the solution now is quit easy -
Just undo all your previous checkout manipulation attempts,
upgrade spree to 1.2.0 by updating your gem file and bundle install,
handle all your code breakups by following their documentation (I guess you'll have some).
and create a simple order_decorator.rb under app/models/spree/

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
  end

  # If true, causes the payment step to happen during the checkout process
  def payment_required?
    return false
  end

  # If true, causes the confirmation step to happen during the checkout process
  def confirmation_required?
    return true
  end

end

enjoy.

In spree >= 2.0.0 you can use following helper method to remove any checkout step. Follow the steps given below.

Step 1: in app/models/spree/ create new file with name order_decorator.rb

Step 2: Copy and paste following code in it.

Spree::Order.class_eval do
#replace :delivery to any other state 
remove_checkout_step :delivery  
end 

Thanks to spree community. http://guides.spreecommerce.com/developer/

Default checkout Steps in Spree

  1. Address
  2. Delivery
  3. Payment
  4. Confirm

Spree(2.0) allows you to modify checkout process to add or remove steps by using respective helpers.

insert_checkout_step
remove_checkout_step

Need to remember that remove_checkout_step will remove just one checkout step at a time:

It works with the new fork of Spree Solidus also

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