fbpx

This is pretty straightforward. All the hooks pass Order ID as a parameter to your function. If you’d like, you can set priority and accepted args in the add_action, but the default priority works for most uses, so I don’t usually bother.

add_action( 'woocommerce_order_status_pending',		'my_custom_function');
add_action( 'woocommerce_order_status_failed',		'my_custom_function');
add_action( 'woocommerce_order_status_on-hold',		'my_custom_function');
// Note that it's "woocommerce_order_status_on-hold", not "on_hold" like you'd expect
add_action( 'woocommerce_order_status_processing',	'my_custom_function');
add_action( 'woocommerce_order_status_completed',	'my_custom_function');
add_action( 'woocommerce_order_status_refunded',	'my_custom_function');
add_action( 'woocommerce_order_status_cancelled',	'my_custom_function');
add_action( 'woocommerce_payment_complete',		'my_custom_function' );
function my_custom_function($order_id) {
    // do stuff here
}