"Order Status Changed" Webhook Topic
Adds an "Order status changed" topic to WooCommerce webhooks, so your integration is told about every status change instead of every order edit.
Opens WPIDE on
Code
add_filter( 'woocommerce_webhook_topic_hooks', function ( $topics ) {
$topics['order.status_changed'] = array( 'woocommerce_order_status_changed' );
return $topics;
} );
add_filter( 'woocommerce_valid_webhook_events', function ( $events ) {
$events[] = 'status_changed';
return $events;
} );
add_filter( 'woocommerce_webhook_topics', function ( $topics ) {
$topics['order.status_changed'] = 'Order status changed';
return $topics;
} );
Notes
Choose "Order status changed" when creating a webhook under WooCommerce > Settings > Advanced > Webhooks; the payload is the full order.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.