我已经编写了这个函数并将它放在我的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');
答案 0 :(得分:0)
WooCommerce Docs建议你可能会追随的钩子是:
woocommerce_subscription_payment_complete
或
woocommerce_subscription_renewal_payment_complete
所以我会尝试:
add_action('woocommerce_subscription_payment_complete','custom_add_funds_two');