Created
August 14, 2020 00:50
-
-
Save growdev/c0df380fba043486074feb65f9a02ec6 to your computer and use it in GitHub Desktop.
Toolbox - Send email when customer skips next payment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Send an email notification when a customer skips a subscription shipment. | |
* | |
* @param $subscription | |
* @param $user_id | |
* @param $old_next_date | |
* @param $next_payment_date | |
*/ | |
function sp_toolbox_notify_skip( $subscription, $user_id, $old_next_date, $next_payment_date ) { | |
$to = ''; // recipient of the email | |
$subject = 'Customer Skipped Subscription'; // subject | |
$body = 'Subscription ID: ' . $subscription->get_id() . '<br/>' . PHP_EOL; // Subscription ID | |
$body .= 'Customer User ID: ' . $user_id . '<br/>' . PHP_EOL; // User ID | |
$body .= 'Old Date: ' . $old_next_date . '<br/>' . PHP_EOL; // The old next payment date | |
$body .= 'Next Date' . $next_payment_date . '<br/>' . PHP_EOL; // The new next payment date | |
$headers = array( 'Content-Type: text/html; charset=UTF-8' ); | |
wp_mail( $to, $subject, $body, $headers ); | |
} | |
add_action( 'jgtb_after_skip_next_date', 'sp_toolbox_notify_skip', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment