Digit9 Posted April 8, 2007 Share Posted April 8, 2007 Is there a way to display the number of items I have in stock for a specific item? Say I wanna display a server packages stock. It's ID "0000000008". So if I could get a neat little script to say: print $stock['0000000008']; That would be awesome 0 Quote Link to comment Share on other sites More sharing options...
skshost Posted April 8, 2007 Share Posted April 8, 2007 it wouldn't be that hard, just have to pull it from the database really. 0 Quote Link to comment Share on other sites More sharing options...
Digit9 Posted April 9, 2007 Author Share Posted April 9, 2007 Do you have a little script snippet or something to show me how it's done? I tried doing it myself, but I'm rusty on my PHP skills. 0 Quote Link to comment Share on other sites More sharing options...
trine Posted April 9, 2007 Share Posted April 9, 2007 (If you're rusty, you can polish up! :mrgreen:) Not sure .. but you may want to see if {$product.qty} works first (that is if the $product array is available in the template you are trying to use). otherwise, my recommended way is to add a smarty function (in whmcs_dir/libs/plugins), since you don't want to see connections strings to a db in your smarty templates. It really depends on you you are doing, but you will need to connect to the db. then do your select: (this will get a result for one GID only. $productpid is assumed passed to the function get it in the $params array ie: $params['pid']) SELECT qty FROM tblproducts WHERE gid=$productpid then pass it back to the template in the function by returning the result. There are many tutorials on Smarty at smarty.php.net 0 Quote Link to comment Share on other sites More sharing options...
skshost Posted April 9, 2007 Share Posted April 9, 2007 you don't want to see connections strings to a db in your smarty templates. To be specific, you wouldn't need a connection string, but I can certainly understand not wanting to display your DB table info. It just depends. I personally would have no problem with it since I've done it before. It's not like anyone else is going to see it, right? Technically if you want to do it right you'll want to get much of your product info and display it as if the product array was already there.. like: {$product.qty}, etc.. Again, this isn't that hard. You'll be on smarty.php.net quite a bit, but also search this forum cause I know there's a few examples of getting from the DB and passing to smarty. Infact I did it just last night.. "Departments Dropdown" 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted April 9, 2007 WHMCS CEO Share Posted April 9, 2007 I presume this is not in the templates that you are trying to do this so you would need to connect to the database using a normal connection routine and then use code such as the following: $query = "SELECT qty FROM tblproducts WHERE id='1'"; $result=mysql_query($query); $data = mysql_fetch_array($result); $qty = $data['qty']; if ($qty=="0") { echo("Currently Out Of Stock"); } else { echo("$qty Available"); } Matt 0 Quote Link to comment Share on other sites More sharing options...
skshost Posted April 9, 2007 Share Posted April 9, 2007 I wonder where you want to display this info? There's not to many places I can imagine needing it outside the order form. 0 Quote Link to comment Share on other sites More sharing options...
Adam Posted April 10, 2007 Share Posted April 10, 2007 I wonder where you want to display this info? There's not to many places I can imagine needing it outside the order form. On custom pages, like I my whole dedicated server page on my site is straight from the database! Example: http://www.eastsolid.com/dedicated/serverSale.php?gid=12&sale=8075-02 From, Adam 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted April 10, 2007 Share Posted April 10, 2007 my whole dedicated server page on my site is straight from the database! I'm impressed - very slick - is it limited to 6 and did you need to know the WHMCS pids or ... ? Any chance of sharing, I'd like to see the php code you used for pulling all the details out. 0 Quote Link to comment Share on other sites More sharing options...
Adam Posted April 10, 2007 Share Posted April 10, 2007 my whole dedicated server page on my site is straight from the database! I'm impressed - very slick - is it limited to 6 and did you need to know the WHMCS pids or ... ? Any chance of sharing, I'd like to see the php code you used for pulling all the details out. No, those are the only stuff in that gid. Ya I'm going to be finishing up version 1.0 of Kayako to WHMCS integration (currently have it working on my WHMCS install). Once I finish up the docs and do some more testing I will work on getting that out as well. From, Adam 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.