Last active
November 29, 2018 17:16
-
-
Save jrick1229/bd5a5bb92e7ed9ae55562e40e293a463 to your computer and use it in GitHub Desktop.
Immediately 'Cancel' the subscription after the fifth payment retry
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 | |
function eg_my_custom_retry_rules( $default_retry_rules_array ) { | |
return array( | |
array( | |
'retry_after_interval' => 3 * DAY_IN_SECONDS, | |
'email_template_customer' => '', | |
'email_template_admin' => 'WCS_Email_Payment_Retry', | |
'status_to_apply_to_order' => 'pending', | |
'status_to_apply_to_subscription' => 'on-hold', | |
), | |
array( | |
'retry_after_interval' => 4 * DAY_IN_SECONDS, | |
'email_template_customer' => 'EG_Email_Customer_Payment_Retry_First_Nag', // custom email | |
'email_template_admin' => '', | |
'status_to_apply_to_order' => 'pending', | |
'status_to_apply_to_subscription' => 'on-hold', | |
), | |
array( | |
'retry_after_interval' => WEEK_IN_SECONDS, | |
'email_template_customer' => '', // avoid spamming the customer by not sending them an email this time either | |
'email_template_admin' => '', | |
'status_to_apply_to_order' => 'pending', | |
'status_to_apply_to_subscription' => 'on-hold', | |
), | |
array( | |
'retry_after_interval' => WEEK_IN_SECONDS, | |
'email_template_customer' => 'EG_Email_Customer_Payment_Retry_Second_Nag', // custom email | |
'email_template_admin' => '', | |
'status_to_apply_to_order' => 'pending', | |
'status_to_apply_to_subscription' => 'on-hold', | |
), | |
array( | |
'retry_after_interval' => WEEK_IN_SECONDS, | |
'email_template_customer' => 'EG_Email_Customer_Payment_Retry_Final_Nag', // custom email | |
'email_template_admin' => 'WCS_Email_Payment_Retry', | |
'status_to_apply_to_order' => 'failed', | |
'status_to_apply_to_subscription' => 'cancelled', | |
), | |
); | |
} | |
add_filter( 'wcs_default_retry_rules', 'eg_my_custom_retry_rules' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment