Description
User Story
As a developper, I want to customize the default emails for a recurring donation, especially when a subscription is cancelled.
Details
In give-recurring/includes/admin/emails
, files class-subscription-cancelled-email.php
, class-subscription-cancelled-admin-email.php
and class-subscription-completed-email.php
.
In the Give_Subscription_Cancelled_Email
, Give_Subscription_Completed_Email
, Give_Subscription_Cancelled_Admin_Email
classes, the default email message does not have a hook.
There is a hook to display the message:
return apply_filters( "give_{$this->config['id']}_get_email_message", $message, $this );
But this hook has no impact on the email displayed in the settings. It has an impact on the preview email which will therefore be different and the sent email. If this email is configured in the settings, it will be overwritten by this hook.
Suggested solution
Do the same as in GiveWP : add a get_default_message() function with a hook, and maybe remove that existing hook.
I solved the problem with two hooks:
function give_cart_email_subscription_cancelled( $message ) {
$options = give_get_settings();
if ( ! isset( $options[ 'subscription_cancelled_message' ] ) ) {
return give_cart_default_subscription_cancelled( $message );
}
return $message;
}
add_filter( 'give_subscription-cancelled_get_default_email_message', 'give_cart_email_subscription_cancelled');
add_filter( 'give_subscription-cancelled_get_email_message', 'give_cart_email_subscription_cancelled');