Also how can we display message on cart if in this case the product quantity is out of stock.
I followed up using this: http://www.webassist.com/tutorials/Inventory-management-shopping-cart-IV
I tried a lot . but i think some changes are required in here:
$query_WADAProducts = sprintf("SELECT ProductStock - (SELECT Coalesce(SUM(DetailQuantity),0) FROM orders Inner Join orderdetails ON orderdetails.DetailOrderID = orders.OrderID WHERE OrderDate > ProductUpdateDate AND DetailProductID = ProductID) AS RemainingInventory FROM products WHERE ProductID = %s", GetSQLValueString($IDParam_WADAProducts, "int"));
$WADAProducts = mysql_query($query_WADAProducts, $Sample_Connection) or die(mysql_error());
$row_WADAProducts = mysql_fetch_assoc($WADAProducts);
$totalRows_WADAProducts = mysql_num_rows($WADAProducts);
?>
My tables are Products & ProducBatch
Product contains: ID, ProductName, CatID,
ProductBatch contains, ID, ProductID, ProductPrice, ExpDate, Quantity, BatchName.