You are here

function commerce_email_form_submit in Commerce Email 7

File

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

Code

function commerce_email_form_submit($form, &$form_state) {
  $languages = language_list('enabled');
  $languages = array_keys($languages[1]);
  $email_types = commerce_email_list('enabled');
  foreach ($email_types as $type) {
    foreach ($languages as $lang) {
      db_update('commerce_email')
        ->fields(array(
        'subject' => $form_state['values'][$type . '_subject_' . $lang],
        'content' => $form_state['values'][$type . '_content_' . $lang]['value'],
        'content_format' => $form_state['values'][$type . '_content_' . $lang]['format'],
        'template' => $form_state['values'][$type . '_template_' . $lang],
      ))
        ->condition('type', $form_state['values'][$type . '_type_' . $lang])
        ->condition('language', $lang)
        ->execute();
      variable_set('commerce_email_' . $type . '_template_' . $lang, $form_state['values'][$type . '_template_' . $lang]);
    }
  }
  drupal_set_message(t('Commerce emails updated'));
}