How to override Spree validation forms and step flows?

I am using spree 2.0.0 in my application. I just want to know how I can edit the audit check or how I can completely remove / disable any "step" during the Spree check.

Any thoughts on this?

+4
source share
3 answers

As the documentation , you can use the remove_checkout_step helper method (which is also much clearer than overriding the validation process), for example:

 Spree::Order.class_eval do # ... remove_checkout_step :delivery # ... end 
+10
source

I have found a 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 delete the delivery status, just comment it. You can comment on any step.

Further information can be found in the documentation .

+6
source

Default Validation Steps in Spree

  • Address
  • Delivery
  • Payment
  • Make sure

Spree allows you to modify the validation process to add or remove steps using appropriate helpers.

  • insert_checkout_step
  • remove_checkout_step

In your case, you should go with remove_checkout_step (to remove the verification step) Remove_checkout_step removes only one verification step at a time:

  • remove_checkout_step: address
  • remove_checkout_step: delivery
+3
source

Source: https://habr.com/ru/post/1495524/


All Articles