In this episode, we're laying the groundwork for order status notifications by tackling the challenge of detecting when an order's status actually changes. Not as trivial as it sounds! We're not ready to send emails just yet — that's coming up next — but here we figure out how to reliably know when a status has moved from, say, "pending" to "packaged" or "shipped."
Here's what we do:
getDirty()
and compare changes using the model's "filled statuses", filtering out anything that's just being reverted (for example, setting a date back to null shouldn't count as a status change).By the end of this episode, our logic is spot-on: we can accurately detect when the order status changes and are all set up for sending notifications (which is up next!).