Add an action after a successful payment method added after_woocommerce_add_payment_method

Viewed 31

I'm trying to get it to email me with this test script which works when run on its own from a browser. I just can't get it to trigger in the functions.php of the twentytwentytwo theme. I'm expecting it to trigger as soon as a new card is added to the payment methods in my account?

add_action( 'after_woocommerce_add_payment_method', ‘changesubscriptionpd’ );
function changesubscriptionpd() {
include ‘https://demourl.com/wp-content/themes/twentytwentytwo/mailtest.php’;
}
1 Answers

Send a test mail after adding new payment method using WP mail function wp_mail()

add_action('after_woocommerce_add_payment_method', 'changesubscriptionpd');

function changesubscriptionpd() {
    $to = 'sendto@example.com';
    $subject = 'The subject';
    $body = 'The email body content';
    $headers = array('Content-Type: text/html; charset=UTF-8');

    wp_mail($to, $subject, $body, $headers);
}
Related