RPS Posted February 19, 2008 Share Posted February 19, 2008 This code will take a product id and display the stock, if stock is 0, then it will display an out of stock message. This is useful if you have a product for sale on your website and would like to show everyone the stock available. Put this code somewhere within your php page: <?php # path can be: # /home/user/public_html/whmcs/configuration.php # ../whmcs/configuration.php # whmcs/configuration.php # etc.. require('whmcs/configuration.php'); mysql_connect($db_host, $db_username, $db_password) or die(mysql_error()); mysql_select_db($db_name) or die(mysql_error()); # be sure to modify the 39 and use the product id you wish to display, this is the pid variable found on the shopping cart order link of the product details $result = mysql_query("SELECT qty FROM tblproducts WHERE id = 39 AND stockcontrol = 'on'"); $row = mysql_fetch_row($result); $qty_39 = "(".$row[0]." in stock)"; ?> Use this code whenever you would like to display the product stock. <?php if(!$row[0]) echo $out_of_stock; else echo $qty_39; ?> 0 Quote Link to comment Share on other sites More sharing options...
JasonO Posted February 19, 2008 Share Posted February 19, 2008 Damn RPS - your too kind with these contributions 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.