Introduction

WooCommerce order statuses (like processing, completed, or cancelled) are key touchpoints in the customer journey. But what if you want to automate actions when those statuses change—like sending a Slack alert, triggering an ERP update, or emailing a custom report?

Good news: WooCommerce makes this easy with powerful hooks.

In this guide, you’ll learn how to:

  • Hook into order status changes
  • Trigger Slack messages using webhooks
  • Send custom emails on status change
  • Notify an ERP system or external API

Understanding Order Status Hooks

WooCommerce fires the woocommerce_order_status_changed action whenever an order’s status changes.

Hook signature:

add_action('woocommerce_order_status_changed', 'your_callback_function', 10, 4);

function your_callback_function($order_id, $old_status, $new_status, $order) {
    // Your logic here
}

1. Slack Notification on Status Change

You can use Incoming Webhooks to send Slack messages.

Code Example:

function notify_slack_on_status_change($order_id, $old_status, $new_status, $order) {
    $webhook_url = 'https://hooks.slack.com/services/your/webhook/url';

    $message = [
        'text' => "Order #{$order_id} changed from *{$old_status}* to *{$new_status}*.",
    ];

    wp_remote_post($webhook_url, [
        'headers' => ['Content-Type' => 'application/json'],
        'body'    => json_encode($message),
    ]);
}
add_action('woocommerce_order_status_changed', 'notify_slack_on_status_change', 10, 4);

Customize with order total, customer name, or products.

2. Send Custom Email Notification

WooCommerce doesn’t email on every status change by default. You can manually send custom emails.

Example: Email admin when order moves to “on-hold”

function send_email_on_hold_order($order_id, $old_status, $new_status, $order) {
    if ($new_status === 'on-hold') {
        wp_mail(
            'admin@yourstore.com',
            'Order On Hold Alert',
            "Order #{$order_id} has been placed on hold.\n\nCustomer: " . $order->get_billing_email()
        );
    }
}
add_action('woocommerce_order_status_changed', 'send_email_on_hold_order', 10, 4);

You can extend this by sending different emails for different statuses.

3. Trigger an ERP or External API

To sync order status with an ERP, you can use wp_remote_post() to send data to an external endpoint.

Example:

function send_order_to_erp($order_id, $old_status, $new_status, $order) {    $erp_url = 'https://erp.example.com/api/order-update';
    
    $data = [
        'order_id'   => $order_id,
        'new_status' => $new_status,
        'total'      => $order->get_total(),
        'email'      => $order->get_billing_email(),
    ];

    wp_remote_post($erp_url, [
        'headers' => ['Content-Type' => 'application/json'],
        'body'    => json_encode($data),
    ]);
}
add_action('woocommerce_order_status_changed', 'send_order_to_erp', 10, 4);

Add authentication headers (API key/token) as needed.

Security & Best Practices

  • Validate data before sending to Slack/API.
  • Add logging using error_log() or custom logs.
  • Avoid triggering external APIs during refunds unless required.
  • Use try/catch or wp_remote_retrieve_response_code() to handle failures gracefully.

Real-World Use Cases

  • ERP sync: Update inventory or shipping in Odoo, NetSuite, SAP, etc.
  • Slack alert: Notify fulfillment teams instantly.
  • Webhook trigger: Fire off Make/Zapier flows.
  • Email digest: Custom customer-facing emails (e.g. “your order is now being packed”).

Conclusion

WooCommerce offers flexible and powerful ways to automate your workflows via order status hooks. Whether you’re integrating with Slack, an ERP, or building custom notifications, hooking into woocommerce_order_status_changed unlocks real-time operational efficiency.