uc_stock_adjust
Drupal 7 uc_stock_adjust($sku, $qty, $check_active = TRUE)
Adjusts the product stock level by a set amount.
Parameters
$sku: The product SKU of the stock level to adjust.
$qty: The amount to add to or subtract from the stock level.
$check_active: If FALSE, don't check if stock tracking is active for this SKU.
3 calls to uc_stock_adjust()
File
- sites/
all/ modules/ ubercart/ uc_stock/ uc_stock.module, line 160 - Allow ubercart products to have stock levels associated with their SKU
Code
function uc_stock_adjust($sku, $qty, $check_active = TRUE) {
$stock = db_query("SELECT active, stock FROM {uc_product_stock} WHERE sku = :sku", array(':sku' => $sku))->fetchObject();
if ($check_active) {
if (!$stock || !$stock->active) {
return;
}
}
db_update('uc_product_stock')
->expression('stock', 'stock + :qty', array(':qty' => $qty))
->condition('sku', $sku)
->execute();
module_invoke_all('uc_stock_adjusted', $sku, $stock->stock, $qty);
}

