WooCommerce Subscriptions: Send cancellation emails to customer

By default, Subscription cancellation emails are not sent to the customer. The following code will automatically send the cancellation email to the customer, too.

function subsCustomerCancellationEmails( $subscription ) {
    $customer_email = $subscription->get_billing_email();
    $wc_emails = WC()->mailer()->get_emails();
    $wc_emails['WCS_Email_Cancelled_Subscription']->recipient = $customer_email;
    $wc_emails['WCS_Email_Cancelled_Subscription']->trigger( $subscription );

Please note that this code will only work if you have the WooCommerce Subscriptions extension installed and activated on your WooCommerce site. This code can be added following the instructions here:

How to add custom code to your WooCommerce/WordPress site the right way

Have any feedback? Be sure to let me know here: Contact me

Share your thoughts

Your email address will not be published. Required fields are marked *