As far as I know, if you have to perform an action when a orders' state, shipment_state, and payment_state is "complete", "shipped", and "paid" respectively at the time that the order satisfies those conditions, you're pretty much out of luck.
I would consider an order in those three states to be a "fulfilled" order where all obligations of the merchant to the customer are complete.
I've tried the below before I tried to implement some other custom solution on top of this, or inject behaviour into every state machine.
- Using an after save hook on the order
- Registering an update hook with
Spree::Order.register_update_hook
The first doesn't work because the order updater uses update_columns
The second doesn't work because the several modules, like OrderShipping, uses the updater to calculate the new state, and then persists the state itself. run_hooks only ever being called in OrderUpdater#update!
Does anyone have any suggestions on making this a more fluid and robust process?
As far as I know, if you have to perform an action when a orders' state, shipment_state, and payment_state is "complete", "shipped", and "paid" respectively at the time that the order satisfies those conditions, you're pretty much out of luck.
I would consider an order in those three states to be a "fulfilled" order where all obligations of the merchant to the customer are complete.
I've tried the below before I tried to implement some other custom solution on top of this, or inject behaviour into every state machine.
Spree::Order.register_update_hookThe first doesn't work because the order updater uses
update_columnsThe second doesn't work because the several modules, like
OrderShipping, uses the updater to calculate the new state, and then persists the state itself.run_hooksonly ever being called inOrderUpdater#update!Does anyone have any suggestions on making this a more fluid and robust process?