4

I'm using spree 2.0.0 in my application. I just want to know how i can edit spree checkout or how I can completely remove / disable any "Step" during Spree checkout process.

Any thoughts on this?

notapatch
  • 6,569
  • 6
  • 41
  • 45
Muhammad Ateq Ejaz
  • 1,845
  • 20
  • 22

3 Answers3

11

As Documentation says, you can use remove_checkout_step helper method (which is also much clearer than redefining whole checkout process), for example:

Spree::Order.class_eval do
  # ...
  remove_checkout_step :delivery
  # ...
end
Marek Lipka
  • 50,622
  • 7
  • 87
  • 91
  • Hi Marek. Thanks for your solution its great and definitely it is stated in the spree documentation. Actually i tried it before but when i proceed after filling address fields it redirects me to cart page even i have things already added to cart. It may be application speciic but your answer is definitely is a solution. – Muhammad Ateq Ejaz Aug 06 '13 at 12:11
6

I just found the solution. Here it is.

Step 1:Create app/models/order_decorator.rb file

Step 2: Copy following code in your order_decorator.rb 

Spree::Order.class_eval do
  checkout_flow do
    go_to_state :address
    #go_to_state :delivery
    go_to_state :payment, if: ->(order) {
      order.update_totals
      order.payment_required?
    }
    go_to_state :confirm, if: ->(order) { order.confirmation_required? }
    go_to_state :complete, if: ->(order) {
      (order.payment_required? && order.has_unprocessed_payments?) || !order.payment_required?
    }
    remove_transition from: :delivery, to: :confirm
  end
end

Example: if you want to remove delivery state just comment it out.You can comment out any step.

You can find more info in the documentation.

vishes_shell
  • 22,409
  • 6
  • 71
  • 81
Muhammad Ateq Ejaz
  • 1,845
  • 20
  • 22
4

Default checkout Steps in Spree

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

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

  • insert_checkout_step
  • remove_checkout_step

In your case you should go with remove_checkout_step(to remove checkout step) The remove_checkout_step will remove just one checkout step at a time:

  • remove_checkout_step :address
  • remove_checkout_step :delivery
Arvind singh
  • 1,312
  • 15
  • 15