You are here

function commerce_checkout_action_send_account_email in Commerce Core 7

Action callback: sends a selected account e-mail.

1 string reference to 'commerce_checkout_action_send_account_email'
commerce_checkout_rules_action_info in modules/checkout/commerce_checkout.rules.inc
Implements hook_rules_action_info().

File

modules/checkout/commerce_checkout.rules.inc, line 94
Rules integration for the checkout process.

Code

function commerce_checkout_action_send_account_email($account, $email_type) {

  // If we received an authenticated user account...
  if (!empty($account)) {
    $types = commerce_checkout_account_email_options_list();

    // Attempt to send the account e-mail.
    $result = _user_mail_notify($email_type, $account);

    // Log the success or failure.
    if ($result) {
      watchdog('rules', '%type e-mail sent to %recipient.', array(
        '%type' => $types[$email_type],
        '%recipient' => $account->mail,
      ));
    }
    else {
      watchdog('rules', 'Failed to send %type e-mail to %recipient.', array(
        '%type' => $types[$email_type],
        '%recipient' => $account->mail,
      ));
    }
  }
}