function commerce_usps_settings_form in Commerce USPS 7.2
Same name and namespace in other branches
- 7 commerce_usps.inc \commerce_usps_settings_form()
Form builder function for module settings.
Return value
string Drupal form for USPS settings
1 string reference to 'commerce_usps_settings_form'
- commerce_usps_menu in ./
commerce_usps.module - Implements hook_menu().
File
- includes/
commerce_usps.admin.inc, line 14 - Admin functions for Commerce USPS.
Code
function commerce_usps_settings_form() {
$form['origin'] = array(
'#title' => t('Ship from location'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
);
$form['origin']['commerce_usps_postal_code'] = array(
'#type' => 'textfield',
'#title' => t('Postal Code'),
'#default_value' => variable_get('commerce_usps_postal_code', ''),
);
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Shipment Settings'),
'#collapsible' => TRUE,
);
$usps_services = array();
foreach (commerce_usps_service_list('domestic') as $machine_name => $usps_service) {
$usps_services[$machine_name] = $usps_service['title'];
}
$form['settings']['commerce_usps_services'] = array(
'#type' => 'checkboxes',
'#title' => t('USPS Services'),
'#description' => t('Select the USPS services that are available to customers.'),
'#default_value' => variable_get('commerce_usps_services', array()),
'#options' => $usps_services,
);
$usps_services_int = array();
foreach (commerce_usps_service_list('international') as $machine_name => $usps_service_int) {
$usps_services_int[$machine_name] = $usps_service_int['title'];
}
$form['settings']['commerce_usps_services_int'] = array(
'#type' => 'checkboxes',
'#title' => t('USPS International Services'),
'#description' => t('Select the USPS International services that are available to customers.'),
'#default_value' => variable_get('commerce_usps_services_int', array()),
'#options' => $usps_services_int,
);
$form['api'] = array(
'#type' => 'fieldset',
'#title' => t('USPS Connection Settings'),
'#collapsed' => variable_get('commerce_usps_user', FALSE),
'#collapsible' => TRUE,
);
$form['api']['commerce_usps_connection_address'] = array(
'#type' => 'textfield',
'#title' => t('Connection Address'),
'#default_value' => variable_get('commerce_usps_connection_address', 'http://production.shippingapis.com/ShippingAPI.dll'),
'#description' => t('Leave this set to http://production.shippingapis.com/ShippingAPI.dll unless you have a reason to change it.'),
'#required' => TRUE,
);
$production_access = l(t('production access'), 'https://www.usps.com/business/web-tools-apis/welcome.htm');
$form['api']['commerce_usps_user'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#default_value' => variable_get('commerce_usps_user', ''),
'#description' => t('The username for your USPS account.') . ' <strong>' . t('You must have been granted !production_access for this module to work.', array(
'!production_access' => $production_access,
)) . '</strong>',
'#required' => TRUE,
);
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced options'),
'#collapsed' => TRUE,
'#collapsible' => TRUE,
);
$form['advanced']['commerce_usps_show_logo'] = array(
'#type' => 'checkbox',
'#title' => t('Show USPS logo next to service'),
'#default_value' => variable_get('commerce_usps_show_logo', FALSE),
);
$form['advanced']['commerce_usps_log'] = array(
'#type' => 'radios',
'#title' => t('Log messages from this module (useful for debugging)'),
'#options' => array(
0 => t('Do not log messages'),
1 => t('Log messages'),
),
'#default_value' => variable_get('commerce_usps_log', 0),
);
$form['actions'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'form-actions',
),
),
'#weight' => 40,
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save USPS settings'),
);
return $form;
}