You are here

function commerce_multicurrency_handling_settings_form in Commerce Multicurrency 7

Form to configure handling settings.

1 string reference to 'commerce_multicurrency_handling_settings_form'
commerce_multicurrency_menu in ./commerce_multicurrency.module
Implements hook_menu().

File

./commerce_multicurrency.admin.inc, line 191
Administrative UI for commerce currency.

Code

function commerce_multicurrency_handling_settings_form($form, &$form_state) {
  $enabled_currencies = commerce_currencies(TRUE);
  $form['currency_fields'] = array(
    '#tree' => TRUE,
  );

  // Just provide this settings if there actually are product types.
  if (function_exists('commerce_product_types')) {
    foreach (commerce_product_types() as $commerce_product_type => $type_info) {
      $form['currency_fields'][$commerce_product_type] = array(
        '#title' => t('Enable dedicated price fields for %type:', array(
          '%type' => $type_info['name'],
        )),
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
        '#description' => t('For each enabled currency a dedicated price field in the commerce product type %type will be created.', array(
          '%type' => $type_info['name'],
        )),
      );
      foreach ($enabled_currencies as $currency_code => $currency_info) {
        $field_name = 'commerce_price_' . strtolower($currency_code);
        $field_instance = field_info_instance('commerce_product', $field_name, $commerce_product_type);
        $form['currency_fields'][$commerce_product_type][$currency_code] = array(
          '#title' => t($currency_info['name']),
          '#type' => 'checkbox',
          '#default_value' => (int) (!empty($field_instance)),
        );
      }
    }
  }
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save Settings'),
  );
  drupal_set_message(t('Attention: Changing this configuration can lead to data loss.'), 'warning', FALSE);
  return $form;
}