Can I Automate an Action on a WooCommerce Order Status?
How to Hook Into a WooCommerce Status Change
WooCommerce fires a specific action for each status an order transitions into, letting custom code react precisely to the transition that matters, without needing to poll or check status manually elsewhere.
add_action( 'woocommerce_order_status_completed', function( $order_id ) {
$order = wc_get_order( $order_id );
// Example: notify an external fulfillment system.
wp_remote_post( 'https://example.com/fulfillment-webhook', [
'body' => wp_json_encode( [ 'order_id' => $order_id ] ),
] );
} );
Common Automation Use Cases
- Notifying an external fulfillment or shipping system when an order reaches Processing, so a third-party warehouse or dropshipper can begin fulfillment automatically.
- Assigning a customer role or granting access when an order Completes, common for a digital product or membership granting entitlement.
- Syncing order data to a CRM or accounting system at a specific status, keeping external records in sync without manual export/import.
- Sending a custom notification (Slack, SMS, an internal alert) for high-value orders reaching a specific status, useful for operational awareness beyond the default email system.
Building This Reliably
- Use the specific status hook for the exact transition that matters, rather than a more general hook requiring extra status-checking logic.
- Handle failures gracefully in the automation itself (a failed webhook call, for instance), since this runs as part of the checkout/admin request and shouldn't break the order update if the external action fails.
- Test thoroughly across the specific transitions the automation is meant to trigger on, including any that might happen via bulk action rather than an individual order.
Need custom order automation built and properly tested? See custom WooCommerce development.