You are here

function uc_stock_add_to_cart in Ubercart AJAX Cart 6

File

./uc_ajax_cart.module, line 507

Code

function uc_stock_add_to_cart($nid, $qty, $data) {
  $product = node_load($nid);
  uc_product_load($product);
  $sql = "SELECT nid FROM {uc_product_stock} WHERE sku = '%s' AND nid = '%s' AND threshold > stock ";
  $result = db_fetch_object(db_query($sql, $product->model, $nid));
  if (db_affected_rows($result) == 1) {
    return array(
      array(
        'success' => false,
        'message' => t('Product out of stock'),
      ),
    );
  }
}