theWebalyst Posted March 15, 2011 Share Posted March 15, 2011 Here is some code showing how to grab price and options info from the database and display it automatically, without the need to re-code your pages whenever you change product price or other settings. This is a pre-Widgets solution and so works with versions earlier than v4.4. I decided to post this as a "How To" because while there are some useful posts on this area most were incomplete or not general enough and it seems like a common requirement. For example, I am grateful for the following thread which I borrowed heavily from: http://forum.whmcs.com/showthread.php?t=23273 My simplified code below should help people adapt this approach to their application more easily. If you save it as PHP and edit the paths in the "require" statements it renders a page with two tables. One of your domain registration pricing, and one showing your hosting plans in each currency. For example: Domain Pricing Extension Price .co.uk £0.00 .co.uk £0.00 .com £8.45 .com £13.49 .org £8.45 .org £13.49 .net £8.45 .net £13.49 .eu £16.95 .eu £26.95 Hosting Plans Hosting Plan Pay Monthly Pay Annually Freelance/Practitioner £3.99 £39.95/year (£3.33/month) Freelance/Practitioner $6.99 $67.95/year ($5.66/month) Fully Managed Hosting (Freelance/Practitioner) N/A £97.00/year (£8.08/month) Fully Managed Hosting (Freelance/Practitioner) N/A $169.00/year ($14.08/month) Freelance/Practitioner €4.99 €49.95/year (€4.16/month) Fully Managed Hosting (Freelance/Practitioner) N/A €125.00/year (€10.42/month) Professional £7.49 £79.95/year (£6.66/month) Professional $12.99 $139.95/year ($11.66/month) Professional €9.99 €99.95/year (€8.33/month) Corporate £9.99 £99.95/year (£8.33/month) Corporate $16.99 $169.95/year ($14.16/month) Corporate €12.99 €124.95/year (€10.41/month) All Group & Plan Settings <snipped> These are followed by output of more detail information on all your plans (not shown to keep the length of this post managable!). Anyway, here's the code which is fairly self explanatory: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <?php # WHMCS functions (note ./clients is the location of the WHMCS folder) require("clients/dbconnect.php"); require("clients/includes/functions.php"); require("clients/includes/clientareafunctions.php"); require("clients/includes/currencyfunctions.php"); #################################################### # Domain Pricing Table # # This list prices in the -default- currency only echo "<h2>Domain Pricing</h2>"; $result = mysql_query(" SELECT * FROM tblpricing LEFT JOIN tbldomainpricing ON tblpricing.relid = tbldomainpricing.id WHERE tblpricing.type = 'domainregister' ") or die(mysql_error()); echo "<table width='300' border='0' class='mytable'>"; echo "<tr><th>Extension</th><th>Price</th></tr>"; while($row = mysql_fetch_array($result)){ echo "<tr><td>"; echo $row['extension']; echo "</td><td>"; echo "£"; echo $row['msetupfee']; echo "</td></tr>"; } echo "</table>"; #################################################### # HOSTING PLAN TABLE # # This lists prices in -all- currencies. echo "<h2>Hosting Plans</h2>"; $result = mysql_query(" SELECT p.name, p.description, t.monthly, t.quarterly, t.semiannually, t.annually, c.code FROM tblproducts AS p INNER JOIN tblpricing AS t ON t.type='product' AND t.relid = p.id INNER JOIN tblcurrencies AS c ON c.id = t.currency WHERE p.hidden != 'on' AND p.type ='hostingaccount' ") or die(mysql_error()); // Used to map database code to currency symbol $currency_symbol = array( 'USD' => '$', 'GBP' => '£', 'EUR' => '€' // Euro (see http://www.cs.tut.fi/~jkorpela/html/euro.html) ); echo "<table width='300' border='0'>"; echo "<tr valign=top> <th>Hosting Plan</th> <th>Pay Monthly</th> <th>Pay Annually</th> </tr>"; while($row = mysql_fetch_array($result)){ echo "<tr valign=top>"; echo "<td>" . $row['name'] . "</td>"; // Some plans are not available monthly if ($row['monthly'] < 0) echo "<td>N/A</td>"; else echo "<td>" . $currency_symbol[$row['code']] . $row['monthly'] . "</td>"; echo "<td>" . $currency_symbol[$row['code']] . $row['annually'] . "/year (" . $currency_symbol[$row['code']] . round($row['annually']/12,2) . "/month)</td>"; echo "</tr>"; } echo "</table>"; ####################################################### # This shows how to get all settings for Groups & Plans # echo "<h2>All Group & Plan Settings</h2>"; echo "<b>Groups</b><br/>"; $whmcs_group_number = 0; $result_groups = mysql_query(" SELECT DISTINCT tblproducts.gid, tblproductgroups.id, tblproductgroups.name, tblproductgroups.order, tblproducts.type, tblproductgroups.hidden, tblproducts.hidden FROM tblproductgroups, tblproducts WHERE tblproducts.gid = tblproductgroups.id AND tblproducts.type = 'hostingaccount' AND tblproducts.hidden != 'on' AND tblproductgroups.hidden != 'on' ORDER BY tblproductgroups.order ASC ") or die(mysql_error()); while($row = mysql_fetch_assoc($result_groups)){ // populate multi-level array with individual hosting group details echo "<br/>"; foreach ($row as $key => $value){ echo "$whmcs_group_number $key: $value<br/>"; // Debug $whmcs_hosting_groups["$whmcs_group_number"]["$key"] = $value; } $whmcs_group_number++; } echo "<br><b>Plans</b><br/>"; $default_currency='1'; $groupid='1'; # get a list of plans and store them in an array for Smarty $result = mysql_query(" SELECT *, tblproducts.name AS prodname, tblproducts.id AS prodid FROM tblproducts, tblproductgroups, tblpricing WHERE tblpricing.type = 'product' AND tblproducts.id = tblpricing.relid AND tblpricing.currency = '$default_currency' AND tblproducts.gid=tblproductgroups.id AND tblproducts.type='hostingaccount' AND (tblproducts.hidden != 'on' AND tblproductgroups.hidden != 'on') AND tblproducts.gid='$groupid' ORDER BY tblproducts.id ASC ") or die(mysql_error()); $whmcs_plan_number = 0; while($row = mysql_fetch_assoc($result)){ $whmcs_plans[] = $row; # $data is the array created for use in the Smarty template. // populate multi-level array with individual hosting package details echo "<br/>"; foreach ($row as $key => $value){ echo "$key: $value<br/>"; // Debug $whmcs_plans_feature["$whmcs_plan_number"]["$key"] = $value; } $whmcs_plan_number++; $num_plans++; } echo "<br/>Total Plans: $num_plans<br/>"; ?> I haven't gone live yet, but sometime in the next few days you'll be able to see the end result at Managed Website Hosting Mark 0 Quote Link to comment Share on other sites More sharing options...
Hosteris Posted March 17, 2011 Share Posted March 17, 2011 I have a script that shows prices in 3 currencies (but can be in all curencies), and when client clicks "buy now" currency is selected automatically depending their country (MXN for México, EUR for Spain, USD for other countries) you can see it at Hosteris.com *sorry for my bad english 0 Quote Link to comment Share on other sites More sharing options...
theWebalyst Posted March 18, 2011 Author Share Posted March 18, 2011 Hi @BotHaTe, I'd like to use such a script to set the initial default sometime - for info, when I tried your site it stayed with USD but I'm in London UK. As for my code above it is working a treat (though still not public yet - but will be visible at my Managed Website Hosting site soon). I have a simple dropdown populated with currency's I support and control the prices shown using a little CSS and jQuery. None of this requires going to WHMCS (all currency prices are there in the page but only the chosen currency is displayed) so switching currencies is instant. Mark 0 Quote Link to comment Share on other sites More sharing options...
Inetbiz Posted March 21, 2011 Share Posted March 21, 2011 This is alright if the files are owned by the same user. But, no so great if the site is not located within the same user that hosts whmcs script. 0 Quote Link to comment Share on other sites More sharing options...
Dam0 Posted March 28, 2011 Share Posted March 28, 2011 a little suggestion on the SQL above {remove] $result = mysql_query(" SELECT * FROM tblpricing LEFT JOIN tbldomainpricing ON tblpricing.relid = tbldomainpricing.id WHERE tblpricing.type = 'domainregister' ") or die(mysql_error()); {Add} $result = mysql_query(" SELECT * FROM tblpricing LEFT JOIN tbldomainpricing ON tblpricing.relid = tbldomainpricing.id WHERE tblpricing.type = 'domainregister' AND tbldomainpricing.id IS NOT NULL ") or die(mysql_error()); 0 Quote Link to comment Share on other sites More sharing options...
Giannis Posted March 31, 2011 Share Posted March 31, 2011 Hello, i am trying to include this in a joomla article using a plugin which allows you to embed a php file but i get Down for Maintenance An upgrade is currently in progress... Please come back soon... If i call the file directly it works. Any clue? thank you 0 Quote Link to comment Share on other sites More sharing options...
theWebalyst Posted March 31, 2011 Author Share Posted March 31, 2011 @Giannis, That seems to be an issue with Joomla or the plugin so you would be better taking the question to a forum with people who know about them. I can't help, sorry. Mark 0 Quote Link to comment Share on other sites More sharing options...
geek Posted March 31, 2011 Share Posted March 31, 2011 There's a one line javascript code in the Wiki so why would you use that? 0 Quote Link to comment Share on other sites More sharing options...
Giannis Posted March 31, 2011 Share Posted March 31, 2011 can you point a link to that? i was looking but no luck thnx 0 Quote Link to comment Share on other sites More sharing options...
hill7714 Posted May 4, 2011 Share Posted May 4, 2011 Is this what you are looking for? http://wiki.whmcs.com/Widgets The Widgets in WHMCS are a dynamic way for extracting data from WHMCS for use on the pages of your website. 0 Quote Link to comment Share on other sites More sharing options...
barnetpcservices Posted May 7, 2011 Share Posted May 7, 2011 its under Utilities > Link Integration in WHMCS Control Panel 0 Quote Link to comment Share on other sites More sharing options...
Grizzlyware Josh Posted May 12, 2011 Share Posted May 12, 2011 You can use Widgets, why is this so long winded? Only issue with Widgets is that they are JS and may not display prices on all clients computers. 0 Quote Link to comment Share on other sites More sharing options...
disgruntled Posted May 18, 2011 Share Posted May 18, 2011 Only issue with Widgets is that they are JS and may not display prices on all clients computers. You answered your own question, While it is rightly so that a widget will be easier to use not all browsers have javascript enabled, granted it is far less common than you may think but its still a problem. The only thing i can contribute here however is this. If you are going to turn away from widgets and code your own pages then think about your client base. Who are they.. mostly website designers, programers and such. Now think about their job, most often than not they ARE going to have javascript enabled. I mean they want to build the perfect website. That means dynamic and graphically appealing along with other factors ofcourse. Now will you still turn away from those javascript widgets? they are designed to help you out after all and let you concentrate on your MAIN objective. Running your business 0 Quote Link to comment Share on other sites More sharing options...
disgruntled Posted May 18, 2011 Share Posted May 18, 2011 mysql_error() Great to see you catching errors. just dont do this in production, for development its fine but in production you may be throwing out potential security information with the mysql errors. better to log the errors for production than display them. 0 Quote Link to comment Share on other sites More sharing options...
zomex Posted May 18, 2011 Share Posted May 18, 2011 It's worth mentioning that it's not possible to order via WHMCS without javascript (at least on the web20cart) because the order buttons use javascript (onclick). Jakc 0 Quote Link to comment Share on other sites More sharing options...
disgruntled Posted May 19, 2011 Share Posted May 19, 2011 It's worth mentioning that it's not possible to order via WHMCS without javascript (at least on the web20cart) because the order buttons use javascript (onclick). Jakc I was not aware of that as i dont use that cart template but none the less a valid point. 0 Quote Link to comment Share on other sites More sharing options...
mscholten Posted May 29, 2011 Share Posted May 29, 2011 Also a nice "Buy now" button in the list with prices would be nice (so you could easily order it directly). 0 Quote Link to comment Share on other sites More sharing options...
moaa Posted June 29, 2011 Share Posted June 29, 2011 I have a script that shows prices in 3 currencies (but can be in all curencies), and when client clicks "buy now" currency is selected automatically depending their country (MXN for México, EUR for Spain, USD for other countries) you can see it at Hosteris.com *sorry for my bad english I looked at hosteris.com and it looks great. I see you are using Joomla. How did you integrate WHMCS with Joomla and home page looks great too. 0 Quote Link to comment Share on other sites More sharing options...
neltek Posted March 9, 2013 Share Posted March 9, 2013 Is this what you are looking for? http://wiki.whmcs.com/Widgets The Widgets in WHMCS are a dynamic way for extracting data from WHMCS for use on the pages of your website. The widgets in documentation don't seem to have the one liner I see they say you can use widgets to display stuff on your website but can't find the explanation of how? The wiki link seems to be no more? 0 Quote Link to comment Share on other sites More sharing options...
Hosteris Posted March 16, 2013 Share Posted March 16, 2013 Widgets are now Data Feeds http://docs.whmcs.com/Data_Feeds 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 25, 2013 Share Posted March 25, 2013 How did you integrate WHMCS with Joomla and home page looks great too. this may not be how he did it, but there is a Joomla / WHMCS integration package - https://www.gohigheris.com/products/jwhmcs-integrator i've never used it, so I can't comment on it either way, but I came across it on another site and your question jogged my memory. 0 Quote Link to comment Share on other sites More sharing options...
epretorious Posted March 27, 2013 Share Posted March 27, 2013 this may not be how he did it, but there is a Joomla / WHMCS integration package - https://www.gohigheris.com/products/jwhmcs-integrator Is there a Wordpress / WHMCS integration package available? 0 Quote Link to comment Share on other sites More sharing options...
epretorious Posted March 28, 2013 Share Posted March 28, 2013 Is this what you're looking for?http://premium.wpmudev.org/project/whmcs-wordpress-integration/ That seems to be what I'm looking for -- Thanks for sharing, CubicWebs! 0 Quote Link to comment Share on other sites More sharing options...
epretorious Posted April 15, 2013 Share Posted April 15, 2013 Is there a Wordpress / WHMCS integration package available? So far, I've found three WordPress plugins for integrating WHMCS into WordPress: Integrator 3http://wordpress.org/extend/plugins/integrator3/ WHMCS Bridgehttp://wordpress.org/extend/plugins/whmcs-bridge/http://www.whmcs.com/appstore/810/Wordpress-Bridge.htmlhttp://go.zingiri.com/index.phphttps://go.zingiri.com/cart.php?gid=4 WHMCS WordPress Integrationhttp://www.whmcs.com/appstore/484/WHMCS-WordPress-Integration.htmlhttp://premium.wpmudev.org/project/whmcs-wordpress-integration/ I'll be sure to add WordPress plugins as I find others (and to share my experience with each as I sample them). HTH, 0 Quote Link to comment Share on other sites More sharing options...
sahostking Posted April 30, 2013 Share Posted April 30, 2013 I could use this for Wordpress sites. Something to definitely consider. Thanks for the post 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.