You are here

function uc_product_adjustments_form_submit in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_attribute/uc_attribute.admin.inc \uc_product_adjustments_form_submit()
  2. 7.3 uc_attribute/uc_attribute.admin.inc \uc_product_adjustments_form_submit()
1 call to uc_product_adjustments_form_submit()
uc_importer_import in uc_importer/uc_importer.module
Imports an XML document into the database.

File

uc_attribute/uc_attribute.module, line 1302

Code

function uc_product_adjustments_form_submit($form_id, $form_values) {
  foreach ($form_values['body'] as $value) {
    if (!empty($value['model']) && $value['model'] != $form_values['default']) {
      db_query("UPDATE {uc_product_adjustments} SET model = '%s' WHERE nid = %d AND combination = '%s'", $value['model'], $form_values['nid'], $value['combo_array']);
      if (!db_affected_rows()) {
        db_query("INSERT INTO {uc_product_adjustments} (nid, combination, model) VALUES (%d, '%s', '%s')", $form_values['nid'], $value['combo_array'], $value['model']);
      }
    }
    else {
      db_query("DELETE FROM {uc_product_adjustments} WHERE nid = %d AND combination = '%s'", $form_values['nid'], $value['combo_array']);
    }
  }
  drupal_set_message(t('Product adjustments have been saved.'));
  $goto = array(
    $_GET['q'],
  );
  if ($_GET['page']) {
    $goto[] = 'page=' . $_GET['page'];
  }
  return $goto;
}