admin管理员组

文章数量:1130349

I've been trying to find an appropriate action(s) hook to do what I'm describing in my title.

Under My account > payment methods I want any newly saved payment method by the user to be set as default

I noticed the "after_woocommerce_add_payment_method" action under "add_payment_method()" function but I don't think I can simply pass a hidden input for this, especially when there is an existing default method.

"is_default" is what seems to be the identifying attribute for the default saved payment method.

I noticed that the built-in functionality for this is under class-wc-payment-tokens.php, with the function named set_users_default() so I could possibly call this provided I can hook into an action after the payment method ( Token ) has been saved ( to get the Token/method ID ) but before WC redirects to the payment-methods page.

Any ideas if I'm thinking this the right way?

I've been trying to find an appropriate action(s) hook to do what I'm describing in my title.

Under My account > payment methods I want any newly saved payment method by the user to be set as default

I noticed the "after_woocommerce_add_payment_method" action under "add_payment_method()" function but I don't think I can simply pass a hidden input for this, especially when there is an existing default method.

"is_default" is what seems to be the identifying attribute for the default saved payment method.

I noticed that the built-in functionality for this is under class-wc-payment-tokens.php, with the function named set_users_default() so I could possibly call this provided I can hook into an action after the payment method ( Token ) has been saved ( to get the Token/method ID ) but before WC redirects to the payment-methods page.

Any ideas if I'm thinking this the right way?

本文标签: Automatically making a newly saved payment method default in WooCommerce