function uc_stock_edit_form_submit in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_stock/uc_stock.module \uc_stock_edit_form_submit()
- 6.2 uc_stock/uc_stock.admin.inc \uc_stock_edit_form_submit()
Form submission handler for uc_stock_edit_form().
See also
File
- uc_stock/
uc_stock.admin.inc, line 263 - Stock administration menu items.
Code
function uc_stock_edit_form_submit($form, &$form_state) {
foreach (element_children($form_state['values']['stock']) as $id) {
$stock = $form_state['values']['stock'][$id];
db_merge('uc_product_stock')
->key(array(
'sku' => $stock['sku'],
))
->updateFields(array(
'active' => $stock['active'],
'stock' => $stock['stock'],
'threshold' => $stock['threshold'],
))
->insertFields(array(
'sku' => $stock['sku'],
'active' => $stock['active'],
'stock' => $stock['stock'],
'threshold' => $stock['threshold'],
'nid' => $form_state['values']['nid'],
))
->execute();
}
drupal_set_message(t('Stock settings saved.'));
}