Woocommerce订阅挂钩/过滤器不起作用

时间:2016-11-15 10:46:45

标签: php wordpress

我已经编写了这个函数并将它放在我的functions.php中,但由于某种原因它没有触发,我已经尝试过它作为动作和过滤器但没有运气。

// ADD £40 ON SUCCESFUL SUBSCRIPTION PAYMENT (EXAMPLE 2)
function custom_add_funds_two($user_id) {

    // get current user's funds
    $funds = get_user_meta( $user_id, 'account_funds', true );

    // add £40
    $funds = $funds + 40;

    // add funds to user
    update_user_meta( $user_id, 'account_funds', $funds );

}
add_filter('processed_subscription_payment','custom_add_funds_two');

1 个答案:

答案 0 :(得分:0)

WooCommerce Docs建议你可能会追随的钩子是:

woocommerce_subscription_payment_complete

woocommerce_subscription_renewal_payment_complete

Source

所以我会尝试:

add_action('woocommerce_subscription_payment_complete','custom_add_funds_two');