Introduce a PRE_RENEWAL event and matching mail

Created on 4 March 2019, almost 6 years ago
Updated 9 March 2023, almost 2 years ago

(This was originally the issue summary of #3037428: [PP-1] Introduce a TRIAL_ENDING event and matching email . Moving that IS here and postponing #3037428: [PP-1] Introduce a TRIAL_ENDING event and matching email on this issue, since the underlying work is happening here.)

Plan:

  • PreRenewalMail service and twig template
  • Cron loads subscriptions that are a configurable amount of time away from renewal
  • Subscription IDs are queued and processed by the SubscriptionNotify job type
  • Each subscription is loaded, and a RENEWAL_APPROACHING (or similar name) event is thrown
  • An event subscriber reacts to the event and invokes the mail service.

Naming the job SubscriptionNotify cause we'll want to extend this for other notifications in the future.

Question: Since sending emails is a light task, should we queue more than one subscription at a time? Could go up to 25.

Original issue summary

Blocked by #3037428: [PP-1] Introduce a TRIAL_ENDING event and matching email and #3037430: Add a next_renewal field to subscriptions .

Let's add a way to notify customers that their renewal date is approaching, and their card is going to be charged.
Happy to bikeshed the event/mail name (RENEWAL_APPROACHING, RENEWAL_SOON?)

📌 Task
Status

Needs work

Version

1.0

Component

Code

Created by

🇷🇸Serbia bojanz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇪🇸Spain JoseFran

    Apply patch from #35 cause us the next error about DependencyInjection.

    ArgumentCountError: Too few arguments to function Drupal\commerce_recurring\RecurringOrderManager::__construct(), 2 passed in /var/www/web/core/lib/Drupal/Component/DependencyInjection

    Testing with commerce_recurring v1.0.0-rc1.

  • 🇮🇳India shabana.navas

    > Reminder before the subscription ends (e.g., when someone scheduled their subscription for cancellation)

    Based on the above comment, this patch adds a new event to send Precancellation emails.

    It also cleans up the above patch. Tests still need work.

  • 🇮🇳India shabana.navas

    Update `enqueueRenewalNotifications()` so that it only sends if there are NO scheduled cancellations queued up for the subscription order.

  • 🇲🇺Mauritius whiz11

    Rerolling this patch to make it D10 compatible, since the eventDispatcher dispatch function arguments are different now

  • rerolled for the post 8.x-1.0-rc3 dev version on D10. This applies, but it also pulling the following error:

    Deprecated function: Creation of dynamic property Drupal\commerce_recurring\Form\BillingScheduleForm::$notificationManager is deprecated in Drupal\commerce_recurring\Form\BillingScheduleForm->__construct() (line 56 of /code/web/modules/contrib/commerce_recurring/src/Form/BillingScheduleForm.php)

  • 🇺🇸United States 3cwebdev

    Same issue for me as @tonka67, getting error when editing or saving a Billing Schedule:

    Error message
    Deprecated function: Creation of dynamic property Drupal\commerce_recurring\Form\BillingScheduleForm::$notificationManager is deprecated in Drupal\commerce_recurring\Form\BillingScheduleForm->__construct() (line 56 of modules/contrib/commerce_recurring/src/Form/BillingScheduleForm.php). 
Production build 0.71.5 2024