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?

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.