Hi,
I need to run some code once the order is fully paid for. I have tried
using after transition to ready in Shipment:
Spree::Shipment.class_eval do
self.state_machine.after_transition :to => :ready, :do => :
do_something_important
def do_something_important
Rails.logger.info "Being very important"
end
end
I also tried something similar in Payment:
Spree::Payment.class_eval do
self.state_machine.after_transition :to => 'complete', :do =>
:do_something_important
def do_something_important
Rails.logger.info "Being very important"
end
end
I specify a cheque payment in the order, and then using the admin backend,
I mark the cheque as having being lodged, and paid for.
In my logs, I am seeing the following inserts into the spree_state_changes
table:
INSERT INTO "spree_state_changes" ("created_at", "name", "next_state",
"previous_state", "stateful_id", "stateful_type", "updated_at", "user_id")
VALUES ('2013-10-07 14:44:35.958000', 'shipment', 'ready', 'pending', 6,
'Spree::Order', '2013-10-07 14:44:35.958000', 1) RETURNING "id"
Is there something glaringly obvious that I'm not doing?