How to replace an existing state machine
We'll see how you can flat-out replace state machines with your custom implementation. Not something you'll need every day, as it comes with its drawbacks, but it can bring you a lot of flexibility if needed.
A custom state machine can be specified through the
state_machines option in
For instance, if you wanted to replace the payment state machine, you could create your own one like this:
# frozen_string_literal: true
state_machine initial: :custom_state do
# Event, transition & hook definitions
And then you'd need to tell Solidus to use it:
Spree.config do |config|
config.state_machines.payment = 'MyStore::StateMachines::Payment'