You are here

function commerce_pricelist_draggable_form_submit in Commerce Pricelist 7

Submit callback for the commerce_pricelist_draggable_form form.

Updates the 'weight' column for each element in our table, taking into account that item's new order after the drag and drop actions have been performed.

File

includes/commerce_pricelist.admin.inc, line 402
Summary

Code

function commerce_pricelist_draggable_form_submit($form, &$form_state) {

  // Because the form elements were keyed with the item ids from the database,
  // we can simply iterate through the submitted values.
  foreach ($form_state['values']['pricelists'] as $id => $item) {
    db_query("UPDATE {commerce_pricelist_list} SET weight = :weight, status = :status WHERE list_id = :id", array(
      ':weight' => $item['weight'],
      ':status' => $item['status'],
      ':id' => $id,
    ));
  }
}