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.
Spree::Auth::Config[:registration_step]
configuration settingspree_frontend
and spree_auth_devise
gems.Spree::Order
state machine. The spree_auth_devise
gem (an extension that comes with Spree Starter by default) adds the check_registration
before filter to all actions of Spree::CheckoutController
except for obvious reasons the registration
and update_registration
actions, which redirects to a registration page unless one of the following is true:
Spree::Auth::Config[:registration_step]
preference is not true
config/initializers/spree.rb
:
config/initializers/spree.rb
:
confirmation_required?
method in Spree::Order
, eg.
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: