add_action( 'woocommerce_order_status_changed', 'wc_order_status_changed', 99, 3 ); function wc_order_status_changed( $order_id, $old_status, $new_status ){ if( $new_status == "cancelled" || $new_status == "refunded" ) {
If you want to use in some class actions, it should be like this:
add_action( 'woocommerce_order_status_changed', array($this, 'wc_order_status_changed'), 99, 3 );
source share