Skip to content

Instantly share code, notes, and snippets.

@jrick1229
Last active November 29, 2018 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrick1229/8564ddff519d420869c75899a9190f05 to your computer and use it in GitHub Desktop.
Save jrick1229/8564ddff519d420869c75899a9190f05 to your computer and use it in GitHub Desktop.
Email customer immediately upon first failed payment
<?php
function wcs_my_custom_retry_rules( $default_retry_rules_array ) {
return array(
array(
'retry_after_interval' => DAY_IN_SECONDS / 2, // how long to wait before retrying
'email_template_customer' => 'WCS_Email_Customer_Payment_Retry', // email customer immediately upon first failed payment
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
array(
'retry_after_interval' => DAY_IN_SECONDS / 2,
'email_template_customer' => 'WCS_Email_Customer_Payment_Retry',
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
array(
'retry_after_interval' => DAY_IN_SECONDS,
'email_template_customer' => 'WCS_Email_Customer_Payment_Retry',
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
array(
'retry_after_interval' => DAY_IN_SECONDS * 2,
'email_template_customer' => 'WCS_Email_Customer_Payment_Retry',
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
array(
'retry_after_interval' => DAY_IN_SECONDS * 3,
'email_template_customer' => 'WCS_Email_Customer_Payment_Retry',
'email_template_admin' => 'WCS_Email_Payment_Retry',
'status_to_apply_to_order' => 'pending',
'status_to_apply_to_subscription' => 'on-hold',
),
);
}
add_filter( 'wcs_default_retry_rules', 'wcs_my_custom_retry_rules' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment