Learn how to customize the checkout process in Spree.
Spree::Order
class.
The default checkout flow for Spree is defined like this, adequately demonstrating the abilities of this new system:
remove_transition
method of the Checkout DSL. The resulting transitions between states look like the image below:
These two helper methods are provided on Spree::Order
instances for your convenience:
checkout_steps
- returns a list of all the potential states of the checkout.has_step?
- Used to check if the current order fulfills the requirements for a specific state.checkout_steps
method, which will return the steps in an array.
config/initializers/spree.rb
:
confirmation_required?
method in Spree::Order
with a decorator, eg.
app/models/spree/order_decorator.rb
file:
valid_zip_code?
method, and then tell the state machine to run this method before that transition, placing this code in a file called app/models/spree/order_decorator.rb
:
delivery
step if valid_zip_code?
returns false.
insert_checkout_step
method takes a before
or after
option to determine where to insert the step:
remove_checkout_step
will remove just one checkout step at a time:
checkout_flow
helper: