function uc_stock_edit_form_submit in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_stock/uc_stock.admin.inc \uc_stock_edit_form_submit()
- 7.3 uc_stock/uc_stock.admin.inc \uc_stock_edit_form_submit()
File
- uc_stock/
uc_stock.module, line 204
Code
function uc_stock_edit_form_submit($form_id, $form_values) {
foreach (element_children($form_values['stock']) as $id) {
db_query("UPDATE {uc_product_stock} SET active = %d, stock = %d, threshold = %d WHERE sku = '%s'", $form_values['stock'][$id]['active'] ? 1 : 0, intval($form_values['stock'][$id]['stock']), intval($form_values['stock'][$id]['threshold']), $form_values['stock'][$id]['sku']);
if (!db_affected_rows()) {
db_query("INSERT INTO {uc_product_stock} (sku, nid, active, stock, threshold) VALUES ('%s', %d, %d, %d, %d)", $form_values['stock'][$id]['sku'], $form_values['nid'], $form_values['stock'][$id]['active'] ? 1 : 0, intval($form_values['stock'][$id]['stock']), intval($form_values['stock'][$id]['threshold']));
}
}
drupal_set_message(t('Stock settings saved.'));
}