You are here

function commerce_promotion_user_presave in Commerce Core 8.2

Implements hook_user_presave().

File

modules/promotion/commerce_promotion.module, line 32
Provides a UI for managing promotions.

Code

function commerce_promotion_user_presave(UserInterface $account) {
  if ($account
    ->isNew()) {
    return;
  }
  $old_mail = $account->original
    ->getEmail();
  $new_mail = $account
    ->getEmail();
  if ($old_mail && $new_mail && $old_mail != $new_mail) {
    \Drupal::service('commerce_promotion.usage')
      ->reassign($old_mail, $new_mail);
  }
}