DMN31 Posted January 25, 2014 Share Posted January 25, 2014 Hey everyone, Thought I'd ask the forum since I can't find it so far, but currently on our site for products we use a generic "Customize Now" button and it links off to the WHMCS product URL. If the product is available, they can customize and purchase, if it's not, they get the Product Out of Stock screen. Is it possible to create a button that will display as Sold Out or something of that nature when Quantity Limit = 0? Seen people do it with other systems but not WHMCS so I wasn't sure. Hopefully that makes sense. Thanks everyone 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 26, 2014 Share Posted January 26, 2014 almost certainly possible - but which order form template are you wanting to try this with? "Comparison" seems to disable the order now button, but I just did a quick test in "Modern", and you could do this with an if statement. 0 Quote Link to comment Share on other sites More sharing options...
DMN31 Posted January 26, 2014 Author Share Posted January 26, 2014 almost certainly possible - but which order form template are you wanting to try this with? "Comparison" seems to disable the order now button, but I just did a quick test in "Modern", and you could do this with an if statement. We're using the "Cart" form. One thing to note, our HTML page with all of our products is an HTML page that doesn't link off to WHMCS until you hit the "Order Now" button. Not sure if that effects this at all. This is the page I was hoping was possible to have a button that could pick up on the inventory, 0 Quote Link to comment Share on other sites More sharing options...
bear Posted January 26, 2014 Share Posted January 26, 2014 our HTML page with all of our products is an HTML page that doesn't link off to WHMCS until you hit the "Order Now" button. Not sure if that effects this at all. HTML pages won't render PHP code without telling the server to parse it for PHP (not recommended). It couldn't be done dynamically on those pages. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 26, 2014 Share Posted January 26, 2014 ok, missed the bit that you were doing this external to whmcs... there are two possible solutions that I can think of for this: you'll either have to query the database - the link below will likely be out of date, but might be some guide if you want to go down this road.. http://forum.whmcs.com/showthread.php?9222-Display-Stock-for-Products&highlight=stock or perhaps write a data feed to get the information for you... http://docs.whmcs.com/Data_Feeds the variable you're looking to use is $product.qty - if stock control is disabled, the variable won't exist; if enabled, it's value will be the stock level. 0 Quote Link to comment Share on other sites More sharing options...
DMN31 Posted January 31, 2014 Author Share Posted January 31, 2014 ok, missed the bit that you were doing this external to whmcs... there are two possible solutions that I can think of for this: you'll either have to query the database - the link below will likely be out of date, but might be some guide if you want to go down this road.. http://forum.whmcs.com/showthread.php?9222-Display-Stock-for-Products&highlight=stock or perhaps write a data feed to get the information for you... http://docs.whmcs.com/Data_Feeds the variable you're looking to use is $product.qty - if stock control is disabled, the variable won't exist; if enabled, it's value will be the stock level. This actually was VERY useful since I had been considering pulling pricing in - thanks! One question involving pulling pricing, is it possible to remove "USD" from the value it pulls? Currently it's pulling this in "$65.00 USD" but ideally I'd prefer "$65.00"? I'm using this data feed: <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price &billingcycle=monthly"></script> 0 Quote Link to comment Share on other sites More sharing options...
DMN31 Posted January 31, 2014 Author Share Posted January 31, 2014 ok, missed the bit that you were doing this external to whmcs... there are two possible solutions that I can think of for this: you'll either have to query the database - the link below will likely be out of date, but might be some guide if you want to go down this road.. http://forum.whmcs.com/showthread.php?9222-Display-Stock-for-Products&highlight=stock or perhaps write a data feed to get the information for you... http://docs.whmcs.com/Data_Feeds the variable you're looking to use is $product.qty - if stock control is disabled, the variable won't exist; if enabled, it's value will be the stock level. Hey Brian, Thank you for this, the data feed option actually answered a little site clean-up project I had been looking into! I wanted to begin pulling pricing in since managing price changes on 50-75 products each week was brutal. My one question, currently using the below data feed script, it pulls in the price in this format: $65.00 USD - Is it possible to pull it in without the USD? Preferably without the cents (decimals) as well but USD is fine. 0 Quote Link to comment Share on other sites More sharing options...
webpoint Posted April 3, 2014 Share Posted April 3, 2014 Hey Brian, Thank you for this, the data feed option actually answered a little site clean-up project I had been looking into! I wanted to begin pulling pricing in since managing price changes on 50-75 products each week was brutal. My one question, currently using the below data feed script, it pulls in the price in this format: $65.00 USD - Is it possible to pull it in without the USD? Preferably without the cents (decimals) as well but USD is fine. I would like to know that as well:) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 3, 2014 Share Posted April 3, 2014 (edited) apologies for not replying to DNM31 about this sooner, I must have missed the reply. i'll go through a number of options... if your WHMCS only uses one currency, then you could remove the line below (~line 74) from productinfo.php to just output the figure without any currency prefix or suffix ($ and USD): $price = formatCurrency($price); you could then add your currency symbol either in the feed or on the page where you are outputting the feed. if you wanted to just display the amount with no prefix/suffix and with no decimal places, you would replace the above line with... $price = number_format($price, 0); if you want to keep the prefix ($ £ € etc), but remove the suffix (USD, GBP etc), add the line below after the formatCurrency line.. $price = str_replace("USD", "", $price); if you were using multiple currencies, then you could either use multiple string replaces - only one should ever match.. $price = str_replace("USD", "", $price); $price = str_replace("GBP", "", $price); ... or create an array and check against that.. $validsuffix = array("GBP", "USD", "EUR"); $price = str_replace($validsuffix, "", $price); ... or pull the suffixes from the appropriate database table... $suffixresult = select_query("tblcurrencies","suffix"); $data2 = mysql_fetch_array($suffixresult); $validsuffix = $data2['suffix']; $price = str_replace($validsuffix, "", $price); if you wanted to remove the prefix ($ £ € etc), but keep the suffix (USD, GBP etc), then you could query the database as above, but just replace "prefix" for "suffix" in the code. $prefixresult = select_query("tblcurrencies","prefix"); $data3 = mysql_fetch_array($prefixresult); $validprefix = $data3['prefix']; $price = str_replace($validprefix, "", $price); hope that helps. Edited April 4, 2014 by brian! 0 Quote Link to comment Share on other sites More sharing options...
webpoint Posted April 3, 2014 Share Posted April 3, 2014 (edited) Many thanks! Cheers! Edited April 3, 2014 by webpoint 0 Quote Link to comment Share on other sites More sharing options...
webpoint Posted April 4, 2014 Share Posted April 4, 2014 Just one last question from me. -> How to add currency symbol in the feed? We just want to get only prefix => "$100". No decimals and no suffix. Right now we have it this way: $price = number_format($price, 0); $price = str_replace("USD", "", $price); Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 4, 2014 Share Posted April 4, 2014 Just one last question from me. i'll hold you to that! -> How to add currency symbol in the feed?We just want to get only prefix => "$100". No decimals and no suffix. Right now we have it this way: $price = number_format($price, 0); $price = str_replace("USD", "", $price); you could do this by removing the formatCurrency line and using... $price = "$" . number_format($price, 0); 0 Quote Link to comment Share on other sites More sharing options...
webpoint Posted April 4, 2014 Share Posted April 4, 2014 i'll hold you to that! you could do this by removing the formatCurrency line and using... $price = "$" . number_format($price, 0); Thanks:) This works! Cheers! 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.