Created
July 29, 2011 19:06
-
-
Save cmaujean/1114500 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Order.class_eval do | |
attr_accessor :ship_notified | |
# order state machine (see http://github.com/pluginaweek/state_machine/tree/master for details) | |
state_machine :initial => 'cart', :use_transactions => false do | |
event :next do | |
transition :from => 'cart', :to => 'address' | |
transition :from => 'address', :to => 'delivery' | |
transition :from => 'delivery', :to => 'payment' | |
transition :from => 'confirm', :to => 'complete' | |
# note: some payment methods will not support a confirm step | |
transition :from => 'payment', :to => 'confirm', | |
:if => Proc.new { Gateway.current && Gateway.current.payment_profiles_supported? } | |
transition :from => 'payment', :to => 'complete' | |
transition :from => 'complete', :to => 'pending' | |
transition :from => 'pending', :to => 'picking' | |
transition :from => 'picking', :to => 'picked' | |
end | |
event :cancel do | |
transition :to => 'canceled', :if => :allow_cancel? | |
end | |
event :return do | |
transition :to => 'returned', :from => 'awaiting_return' | |
end | |
event :resume do | |
transition :to => 'resumed', :from => 'canceled', :if => :allow_resume? | |
end | |
event :authorize_return do | |
transition :to => 'awaiting_return' | |
end | |
event :pending do | |
transition :to => 'pending', :from => ['picking', 'complete'] | |
end | |
event :picking do | |
transition :to => 'picking', :from => ['pending', 'picked'] | |
end | |
event :picked do | |
transition :to => 'picked', :from => ['picking'] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment