You are here

function uc_stock_level in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 uc_stock/uc_stock.module \uc_stock_level()
  2. 5 uc_stock/uc_stock.module \uc_stock_level()
  3. 6.2 uc_stock/uc_stock.module \uc_stock_level()

Gets the stock level of a particular product SKU.

Parameters

$sku: The Ubercart product SKU of the stock level to return.

Return value

The SKU's stock level, or FALSE if not active.

2 calls to uc_stock_level()
UbercartStockTestCase::testProductStock in uc_stock/tests/uc_stock.test
UbercartStockTestCase::testStockDecrement in uc_stock/tests/uc_stock.test

File

uc_stock/uc_stock.module, line 181
Allow ubercart products to have stock levels associated with their SKU

Code

function uc_stock_level($sku) {
  $stock = db_query("SELECT active, stock FROM {uc_product_stock} WHERE sku = :sku", array(
    ':sku' => $sku,
  ))
    ->fetchObject();
  if ($stock && $stock->active) {
    return $stock->stock;
  }
  return FALSE;
}