根据 woocommerce 文档中的信息:
https
://docs.woocommerce.com/document/subscriptions/develop/action-reference/
动作:woocommerce_subscription_status_changed
,
也应在订阅升级或降级时触发 - switched
,
但它仅适用于以下情况:
active, on-hold, cancelled
这是我的示例代码:
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);
}
上面的代码有效,但订阅切换时无效,我的问题是为什么?