You are here

function uc_fedex_admin_settings in FedEx Shipping 7

Same name and namespace in other branches
  1. 5 uc_fedex.module \uc_fedex_admin_settings()
  2. 6.2 uc_fedex.admin.inc \uc_fedex_admin_settings()
  3. 6 uc_fedex.module \uc_fedex_admin_settings()
  4. 7.2 uc_fedex.admin.inc \uc_fedex_admin_settings()

Default FedEx Web Services API settings.

Records FedEx account information neccessary to use service. Allows testing or production mode. Configures which FedEx services are quoted to customers.

Return value

Forms for store administrator to set configuration options.

1 string reference to 'uc_fedex_admin_settings'
uc_fedex_menu in ./uc_fedex.module
Implementation of hook_menu(). Called when Drupal is building menus. Cache parameter lets module know if Drupal intends to cache menu or not - different results may be returned for either case.

File

./uc_fedex.module, line 220
FedEx Web Services Rate / Available Services Quote

Code

function uc_fedex_admin_settings() {

  /* Container for credentials forms */
  $form['uc_fedex_credentials'] = array(
    '#type' => 'fieldset',
    '#title' => t('Credentials'),
    '#description' => t('Account number and authorization information'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  /* Form to set the developer key */
  $form['uc_fedex_credentials']['uc_fedex_user_credential_key'] = array(
    '#type' => 'textfield',
    '#title' => t('FedEx Web Services API User Key'),
    '#default_value' => variable_get('uc_fedex_user_credential_key', ''),
    '#required' => TRUE,
  );

  //
  // This form will be changed to 'password' field, eventually
  // But it takes too much trouble to re-enter a long password
  // every time I change a form option during development and testing.
  //

  /* Form to set the developer password */
  $form['uc_fedex_credentials']['uc_fedex_user_credential_password'] = array(
    '#type' => 'textfield',
    '#title' => t('FedEx Web Services API Password'),
    '#default_value' => variable_get('uc_fedex_user_credential_password', ''),
    '#required' => TRUE,
  );

  /* Form to set user account number */
  $form['uc_fedex_credentials']['uc_fedex_account_number'] = array(
    '#type' => 'textfield',
    '#title' => t('FedEx Account #'),
    '#default_value' => variable_get('uc_fedex_account_number', 0),
    '#required' => TRUE,
  );

  /* Form to set user meter number */
  $form['uc_fedex_credentials']['uc_fedex_meter_number'] = array(
    '#type' => 'textfield',
    '#title' => t('FedEx Meter #'),
    '#default_value' => variable_get('uc_fedex_meter_number', 0),
    '#required' => TRUE,
  );

  /*
   * Form to set choose between Production and Testing server
   * ***Defaults to Testing!***
   */
  $form['uc_fedex_credentials']['uc_fedex_server_role'] = array(
    '#type' => 'select',
    '#title' => t('FedEx Server Role'),
    '#description' => t('Quotes and shipments requested in Testing mode will not be picked up or charged to your account.'),
    '#options' => array(
      'testing' => t('Testing'),
      'production' => t('Production'),
    ),
    '#default_value' => variable_get('uc_fedex_server_role', 'testing'),
  );

  /*
   * Form to set choose between LIST quotes and ACCOUNT quotes
   * ***Defaults to LIST!***
   */
  $form['uc_fedex_quote_type'] = array(
    '#type' => 'select',
    '#title' => t('FedEx Quote Type'),
    '#description' => t('Choose to present the customer with FedEx list prices or your discounted FedEx account prices. LIST prices only exist for US shipments - if you specify LIST for international shipments you will not receive any quotes.  Note that ACCOUNT prices are accurate only on the PRODUCTION server!'),
    '#options' => array(
      'list' => t('List Prices'),
      'account' => t('Discount Account Prices'),
    ),
    '#default_value' => variable_get('uc_fedex_quote_type', 'list'),
  );

  /* Form to restrict FedEx services available to customer */
  $form['uc_fedex_services'] = array(
    '#type' => 'checkboxes',
    '#title' => t('FedEx Services'),
    '#default_value' => variable_get('uc_fedex_services', _uc_fedex_services()),
    '#options' => _uc_fedex_services(),
    '#description' => t('Select the FedEx services customers are allowed to use.'),
  );

  /* Form to set how the package is handed over to FedEx  */
  $form['uc_fedex_dropoff_type'] = array(
    '#type' => 'select',
    '#title' => t('FedEx Pickup/Dropoff Options'),
    '#default_value' => variable_get('uc_fedex_dropoff_type', _uc_fedex_dropoff_types()),
    '#options' => _uc_fedex_dropoff_types(),
    '#description' => t('Pickup/Dropoff options.  It is assumed that all your packages are using the same method.'),
  );

  /* Form to select FedEx packaging to use */
  $form['uc_fedex_package_type'] = array(
    '#type' => 'select',
    '#title' => t('FedEx Package Type'),
    '#default_value' => variable_get('uc_fedex_package_type', _uc_fedex_package_types()),
    '#options' => _uc_fedex_package_types(),
    '#description' => t('Package Type.  It is assumed that all your packages are using the same packaging.'),
  );

  /* Form to select Residential/Commercial destination address */
  $form['uc_fedex_residential_quotes'] = array(
    '#type' => 'radios',
    '#title' => t('Quote rates assuming destination is a'),
    '#default_value' => variable_get('uc_fedex_residential_quotes', 1),
    '#options' => array(
      0 => t('Commercial address'),
      1 => t('Residential address (extra fees)'),
    ),
  );

  /* Container for markup forms */
  $form['uc_fedex_markups'] = array(
    '#type' => 'fieldset',
    '#title' => t('Markups'),
    '#description' => t('Modifiers to the shipping weight and quoted rate'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  /* Form to select type of rate markup */
  $form['uc_fedex_markups']['uc_fedex_rate_markup_type'] = array(
    '#type' => 'select',
    '#title' => t('Rate Markup Type'),
    '#default_value' => variable_get('uc_fedex_rate_markup_type', 'percentage'),
    '#options' => array(
      'percentage' => t('Percentage (%)'),
      'multiplier' => t('Multiplier (×)'),
      'currency' => t('Addition (!currency)', array(
        '!currency' => variable_get('uc_currency_sign', '$'),
      )),
    ),
  );

  /* Form to select type of rate amount */
  $form['uc_fedex_markups']['uc_fedex_rate_markup'] = array(
    '#type' => 'textfield',
    '#title' => t('FedEx Shipping Rate Markup'),
    '#default_value' => variable_get('uc_fedex_rate_markup', '0'),
    '#description' => t('Markup FedEx shipping rate quote by dollar amount, percentage, or multiplier.'),
  );

  /* Form to select type of weight markup */
  $form['uc_fedex_markups']['uc_fedex_weight_markup_type'] = array(
    '#type' => 'select',
    '#title' => t('Weight Markup Type'),
    '#default_value' => variable_get('uc_fedex_weight_markup_type', 'percentage'),
    '#options' => array(
      'percentage' => t('Percentage (%)'),
      'multiplier' => t('Multiplier (×)'),
      'mass' => t('Addition (!mass)', array(
        '!mass' => '#',
      )),
    ),
  );

  /* Form to select type of weight markup amount */
  $form['uc_fedex_markups']['uc_fedex_weight_markup'] = array(
    '#type' => 'textfield',
    '#title' => t('FedEx Shipping Weight Markup'),
    '#default_value' => variable_get('uc_fedex_weight_markup', '0'),
    '#description' => t('Markup FedEx shipping weight before quote by weight amount, percentage, or multiplier.'),
  );

  /* Form to select packaging type */
  $form['uc_fedex_all_in_one'] = array(
    '#type' => 'radios',
    '#title' => t('Number of Packages'),
    '#default_value' => variable_get('uc_fedex_all_in_one', 1),
    '#options' => array(
      0 => t('Each product in its own package'),
      1 => t('All products in one package'),
    ),
    '#description' => t('Indicate whether each product is quoted as shipping separately or all in one package.'),
  );
  return system_settings_form($form);
}