You are here

function uc_flatrate_admin_method_edit_form_submit in Ubercart 6.2

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

See also

uc_flatrate_admin_method_edit_form()

File

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

Code

function uc_flatrate_admin_method_edit_form_submit($form, &$form_state) {
  if (isset($form_state['values']['mid'])) {
    db_query("UPDATE {uc_flatrate_methods} SET title = '%s', label = '%s', base_rate = %f, product_rate = %f WHERE mid = %d", $form_state['values']['title'], $form_state['values']['label'], $form_state['values']['base_rate'], $form_state['values']['product_rate'], $form_state['values']['mid']);
    drupal_set_message(t("Flat rate shipping method was updated."));
  }
  else {
    db_query("INSERT INTO {uc_flatrate_methods} (title, label, base_rate, product_rate) VALUES ('%s', '%s', %f, %f)", $form_state['values']['title'], $form_state['values']['label'], $form_state['values']['base_rate'], $form_state['values']['product_rate']);
    $mid = db_last_insert_id('uc_flatrate_methods', 'mid');
    $enabled = variable_get('uc_quote_enabled', array());
    $enabled['flatrate_' . $mid] = TRUE;
    variable_set('uc_quote_enabled', $enabled);
    $weight = variable_get('uc_quote_method_weight', array());
    $weight['flatrate_' . $mid] = 0;
    variable_set('uc_quote_method_weight', $weight);
    drupal_set_message(t("Created and enabled new flat rate shipping method."));
  }
  $form_state['redirect'] = 'admin/store/settings/quotes/methods/flatrate';
}