You are here

function commerce_email_enable in Commerce Email 7.2

Implements hook_enable()

File

./commerce_email.install, line 6

Code

function commerce_email_enable() {

  // Make sure the rules created by commerce have been taken into account
  drupal_flush_all_caches();

  // Deactivate default commerce rules to send order email
  $rules_config = rules_config_load('commerce_checkout_order_email');
  if ($rules_config->name) {
    $rules_config->active = FALSE;
    $rules_config
      ->save();
  }

  // Deactivate default commerce rules to create new account
  $rules_config = rules_config_load('commerce_checkout_new_account');
  if ($rules_config->name) {
    $rules_config->active = FALSE;
    $rules_config
      ->save();
  }

  // Add the correct settings to Mail System
  if (module_exists('htmlmail')) {
    mailsystem_set(array(
      'variable_email' => 'HTMLMailSystem',
    ));
  }
  elseif (module_exists('mimemail')) {
    mailsystem_set(array(
      'variable_email' => 'MimeMailSystem',
    ));
  }
}