You are here

function commerce_usps_settings_form_submit in Commerce USPS 7

Same name and namespace in other branches
  1. 7.2 includes/commerce_usps.admin.inc \commerce_usps_settings_form_submit()

Submit handler: saves the usps settings.

File

./commerce_usps.inc, line 102
Admin functions for Commerce USPS.

Code

function commerce_usps_settings_form_submit($form, &$form_state) {
  $fields = array(
    'commerce_usps_postal_code',
    'commerce_usps_services',
    'commerce_usps_markup_type',
    'commerce_usps_markup',
    'commerce_usps_connection_address',
    'commerce_usps_user',
  );
  $services = variable_get('commerce_usps_services', NULL);
  foreach ($fields as $key) {
    if (array_key_exists($key, $form_state['values'])) {
      $value = $form_state['values'][$key];
      variable_set($key, $value);
    }
  }

  // If the selected services have changed then rebuild caches.
  if ($services !== $form_state['values']['commerce_usps_services']) {
    commerce_shipping_services_reset();
    entity_defaults_rebuild();
    rules_clear_cache(TRUE);
    menu_rebuild();
  }
  drupal_set_message(t('The USPS configuration options have been saved.'));
}