You are here

function uc_flatrate_admin_method_edit_form in Ubercart 7.3

Same name and namespace in other branches
  1. 5 shipping/uc_flatrate/uc_flatrate.module \uc_flatrate_admin_method_edit_form()
  2. 6.2 shipping/uc_flatrate/uc_flatrate.admin.inc \uc_flatrate_admin_method_edit_form()

Configures the store default product shipping rates.

See also

uc_flatrate_admin_method_edit_form_submit()

uc_flatrate_admin_method_edit_form_delete()

2 string references to 'uc_flatrate_admin_method_edit_form'
UbercartQuoteTestCase::createQuote in shipping/uc_quote/tests/uc_quote.test
Creates a flat rate shipping quote with optional conditions.
uc_flatrate_menu in shipping/uc_flatrate/uc_flatrate.module
Implements hook_menu().

File

shipping/uc_flatrate/uc_flatrate.admin.inc, line 15
Flat rate shipping method administration menu items.

Code

function uc_flatrate_admin_method_edit_form($form, &$form_state, $mid = 0) {
  if ($mid && ($method = db_query("SELECT * FROM {uc_flatrate_methods} WHERE mid = :mid", array(
    ':mid' => $mid,
  ))
    ->fetchObject())) {
    $form['mid'] = array(
      '#type' => 'value',
      '#value' => $mid,
    );
  }
  else {
    $method = (object) array(
      'title' => '',
      'label' => '',
      'base_rate' => '',
      'product_rate' => '',
    );
  }
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Shipping method title'),
    '#description' => t('The name shown to administrators distinguish this method from other flatrate methods.'),
    '#default_value' => $method->title,
    '#required' => TRUE,
  );
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Line item label'),
    '#description' => t('The name shown to the customer when they choose a shipping method at checkout.'),
    '#default_value' => $method->label,
    '#required' => TRUE,
  );
  $form['base_rate'] = array(
    '#type' => 'uc_price',
    '#title' => t('Base price'),
    '#description' => t('The starting price for shipping costs.'),
    '#default_value' => $method->base_rate,
    '#required' => TRUE,
  );
  $form['product_rate'] = array(
    '#type' => 'uc_price',
    '#title' => t('Default product shipping rate'),
    '#description' => t('Additional shipping cost per product in cart.'),
    '#default_value' => $method->product_rate,
    '#required' => TRUE,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  if (isset($form['mid'])) {
    $form['actions']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#validate' => array(),
      '#submit' => array(
        'uc_flatrate_admin_method_edit_form_delete',
      ),
    );
  }
  return $form;
}