You are here

function commerce_email_list_languages in Commerce Email 7

Returns a list of emails in all languages and automatically adds a version for each enabled language

Parameters

$languages: The assoc array of languages enabled on the site

Return value

array of available emails

1 call to commerce_email_list_languages()
commerce_email_form in ./commerce_email.module
Implements hook_form().

File

./commerce_email.module, line 275
Defines additional menu item and order html email functonality.

Code

function commerce_email_list_languages($languages) {
  $email_list = commerce_email_list();
  foreach ($email_list as $type => $email) {
    foreach ($languages as $lang => $lang_detail) {
      if (!isset($email_list[$type][$lang])) {
        commerce_email_language_add($lang, $email_list[$type][LANGUAGE_NONE]);
      }
    }
  }
  $admin_email = variable_get('admin_email', array());
  if (empty($email_list['admin_order']) && !empty($admin_email['enabled'])) {
    foreach ($languages as $lang => $lang_detail) {
      $email = array(
        'type' => 'admin_order',
        'subject' => 'Customer Order [commerce-order:order-number] from [site:name]',
        'content' => '<p>A customer at [site:name] has just placed an order.</p><p>[commerce-email:order-items]</p><p>You can view the complete order at:&nbsp;[site:url]admin/commerce/orders/[commerce-order:order-id]</p>',
      );
      commerce_email_language_add($lang, (object) $email);
    }
  }
  elseif (!empty($email_list['admin_order']) && empty($admin_email['enabled'])) {
    commerce_email_admin_order_remove();
  }
  return commerce_email_list();
}