License Expiry Email Disable or Configurable

Created on 26 February 2025, 4 months ago

Problem/Motivation

I work with a population that goes through a re-certification process every two years. Whenever they hear or see anything that says "Expire" etc. they do freak out To them, it's something about their certification expiring. Just poor choice of words for this use case.

I would like to disable the email all together. I would be nice if this were configurable for other use cases. I get that it can be customized through twig.

But for now, how would I disable this function? Just remove LicenseExpireNotify.php ?

Comment out ?

$message = $this->pluginManagerMail->mail('commerce_license', 'license_expire', $to, $langcode, $params);

    if ($message['result']) {
      return JobResult::success();
    }

Thank you.

✨ Feature request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States goose2000

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

Comments & Activities

  • Issue created by @goose2000
  • πŸ‡―πŸ‡΅Japan ultrabob Japan

    For anyone needing to do this, like I also did. Here is an example of the hook @joachim mentioned. I personally believe the module should provide options around whether these emails should be sent or not, but in the meantime, something like this should work:

    /**
     * Implements hook_mail_alter().
     *
     * Prevents Commerce License expiry notification emails from being sent.
     */
    function mymodule_mail_alter(&$message) {
      // Intercept the license expiry notification email.
      if ($message['module'] === 'commerce_license' && $message['key'] === 'license_expire') {
        // Prevent the email from being sent.
        $message['send'] = FALSE;
        // Optionally log it.
        // \Drupal::logger('mymodule')->notice('Suppressed license expiry email.');
      }
    }
    
Production build 0.71.5 2024