Based on the information in woocommerce documentation:
https://docs.woocommerce.com/document/subscriptions/develop/action-reference/
The action: woocommerce_subscription_status_changed
,
Should be triggered also when the subscription upgraded or downgraded - switched
,
But it only works on the following situations:
active, on-hold, cancelled
Here is my sample code:
add_action('woocommerce_subscription_status_changed', 'test', 10, 3);
function test( $subscription_id, $old_status, $new_status ) {
global $woocommerce;
$file_content = $subscription_id.' '.$old_status.' '.$new_status;
$filename = '/tmp/test_file.txt';
file_put_contents($filename, $file_content);
}
The code above works, but not when the subscription switched, my question is why ?