jbougeno Posted June 19, 2008 Share Posted June 19, 2008 Note: The following only works if your Joomla site resides on the same server as your WHMCS database or otherwise has some kind of access to the WHMCS database. If you're trying to display your WHMCS price list in a Joomla module, you'll first want to download and install a PHP module that allows for putting PHP code into modules. You can find a module at the Joomla Extensions site which also leads to this one that I used successfully at this site: http://www.fijiwebdesign.com/products/joomla-php-module.html. Next, cut and paste the following code into the PHP module. You'll need to modify the database name and password accordingly: <html> <style> table.mytable { width: 100%; padding: 0px; border: none; border: 1px solid #789DB3;} table.mytable td { font-size: 12px; border: none; background-color: #F4F4F4; vertical-align: middle; padding: 7px; font-weight: normal; } table.mytable tr.special td { border-bottom: 1px solid #ff0000; } </style> <head> <title>Domain Prices</title> </head> <body> Registration price per year, maximum of 10 years <?php mysql_connect("localhost", "whmcs_database_name", "whmcs_database_password") or die(mysql_error()); mysql_select_db("whmcs_database_name") or die(mysql_error()); $result = mysql_query("SELECT * FROM tbldomainpricing where registrationperiod = 1 order by extension") or die(mysql_error()); echo "<table width='300' border='0' class='mytable'>"; echo "<tr> <th>TLD</th> <th>Min. Years</th> <th>Register</th> <th>Transfer</th> <th>Renew</th> </tr>"; while($row = mysql_fetch_array($result)){ echo "<tr><td>"; echo $row['extension']; echo "</td><td><center>"; echo $row['registrationperiod']; echo "</center></td><td>"; echo "$"; echo $row['register']; echo "</td><td>"; echo "$"; echo $row['transfer']; echo "</td><td>"; echo "$"; echo $row['renew']; echo "</td></tr>"; } echo "</table>"; ?> </body> </html> Display the module on a page, create a menu link to the page and your prices should show up! Of course, you should make sure you've already created the price listing in WHMCS before doing this procedure. If you want to show your hosting packages, insert the following code into a separate PHP module and your hosting packages will show! <html> <style> table.mytable { width: 100%; padding: 0px; border: none; border: 1px solid #789DB3;} table.mytable td { font-size: 12px; border: none; background-color: #F4F4F4; vertical-align: middle; padding: 7px; font-weight: normal; } table.mytable tr.special td { border-bottom: 1px solid #ff0000; } </style> <head> <title>Prices</title> </head> <body> <?php mysql_connect("localhost", "whmcs_database_name", "whmcs_database_password") or die(mysql_error()); mysql_select_db("whmcs_database_name") or die(mysql_error()); $result = mysql_query("SELECT * FROM tblproducts") or die(mysql_error()); echo "<table width='500' border='0' class='mytable'>"; echo "<tr> <th>Name</th> <th>Description</th> <th>Monthly</th> <th>Semi-Annual</th> <th>Annual</th> </tr>"; while($row = mysql_fetch_array($result)){ echo "<tr><td>"; echo $row['name']; echo "</td><td><center>"; echo $row['description']; echo "</center></td><td>"; echo "$"; echo $row['monthly']; echo "</td><td>"; echo "$"; echo $row['semiannual']; echo "</td><td>"; echo "$"; echo $row['annual']; echo "</td></tr>"; } echo "</table>"; ?> </body> </html> Now that you know how to do this, you can display just about anything from the WHMCS database inside Joomla! 0 Quote Link to comment Share on other sites More sharing options...
goddess_dix Posted June 22, 2008 Share Posted June 22, 2008 Thank you for this. I'm betting I could adapt this to display price stuff in a Drupal site as well. 0 Quote Link to comment Share on other sites More sharing options...
sastrugi Posted August 6, 2008 Share Posted August 6, 2008 Hi, Can I ask if this is for Joomla v1.0.x or v1.5.x ?? Regards, Steve 0 Quote Link to comment Share on other sites More sharing options...
jbougeno Posted August 7, 2008 Author Share Posted August 7, 2008 Well, I did this in Joomla v1.0.x. The PHP itself shouldn't care what version of Joomla it's on. The PHP code is actually pretty minimal and basic. The whole thing that you see is actually a mix of HTML, CSS and PHP with MySQL statements. I didn't write the code myself but rather lifted it from other sources and modified it as needed for my situation. The problem comes up when you try to put any PHP code into a module when using Joomla v1.0.x. It's been my experience that Joomla by default doesn't allow anything in modules except HTML and CSS. The fijiwebdesign.com module allows you to put PHP code into a module which Joomla otherwise wouldn't let you do. That's why I recommended downloading the module from fijiwebdesign.com. If you look at their site, they have a separate version for Joomla v1.5 so I'm guessing the same problem occurs in that version also. Once you've downloaded the module, simply copy the code from this thread and paste it into the module. Be sure to customize the code for your installation as needed. 0 Quote Link to comment Share on other sites More sharing options...
sastrugi Posted August 7, 2008 Share Posted August 7, 2008 Many thanks for the info!! 0 Quote Link to comment Share on other sites More sharing options...
goddess_dix Posted December 30, 2008 Share Posted December 30, 2008 small additions to this code for others, since i modded it, i thought i'd share...if you'd like to only display _hosting packages_ where the display is set to not be hidden in your whmcs, in order from most expensive to least expensive hosting package, use this select statement instead... $result = mysql_query("SELECT * FROM tblproducts WHERE tblproducts.hidden != 'on' AND tblproducts.type ='hostingaccount' ORDER by annual DESC") to bold the package name and link the name to add that package to the cart, change this section - while($row = mysql_fetch_array($result)){ echo "<tr><td>"; echo "<b><a href='http://your.whmcs.com/cart.php?a=add&pid="; echo $row['id']; echo "' title='Order this package'>"; echo $row['name']; echo "</a></b></td><td><center>"; i'm not much of a coder, so it took me a bit to work this out. hope it saves someone else some work. 0 Quote Link to comment Share on other sites More sharing options...
markholland8 Posted January 23, 2009 Share Posted January 23, 2009 Hi, Getting the follwing code error. Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'webdesig_billing'@'localhost' (using password: YES) in /home/webdesig/public_html/modules/mod_php/mod_php.php(36) : eval()'d code on line 15 Database and username is ok please help. Thanks Mark 0 Quote Link to comment Share on other sites More sharing options...
Hosteris Posted April 24, 2009 Share Posted April 24, 2009 Hi, how can I show prices of diferent currency? eg. productsUSD.html (?currency=1) productsEUR.html (?currency=2) (v4.0) Regards. 0 Quote Link to comment Share on other sites More sharing options...
jbougeno Posted April 24, 2009 Author Share Posted April 24, 2009 BotHaTe, You'll need to use PHP & MySQL to pull the currency depending on whether you want USD or Euro. To start off with, you'll need to have a field in the database that tracks whether a currency value is in USD or Euro. I don't know if the database already has that field in it but if not, create it and use a value of 1 for USD and 2 for Euro. When someone selects one or the other, the value should be stored in the field. When you want to display what currency was selected, simply do something like a CASE statement or IF/Then statement, so that if the field value is 1, using PHP and HTML to display "USD" and if the field value is 2, display "Euro". If you're not familiar with PHP and MySQL syntax, then do a Google search for those two and you'll find many tutorials on how to use the two together to do the above scenario that I described for you. Joe 0 Quote Link to comment Share on other sites More sharing options...
Hosteris Posted April 26, 2009 Share Posted April 26, 2009 Thanks Joe. working in the solution... Regards. 0 Quote Link to comment Share on other sites More sharing options...
Hosteris Posted April 26, 2009 Share Posted April 26, 2009 finally !! ok, only "hosting and other products", prices of domain in develop, but, thats all for sunday... *SFMBE 0 Quote Link to comment Share on other sites More sharing options...
jbougeno Posted April 26, 2009 Author Share Posted April 26, 2009 BotHaTe, I'm glad to hear you're making progress. Be sure to post your solution on this thread so others can use it if they run into the same problems or in case they can use it to build a solution for another problem. 0 Quote Link to comment Share on other sites More sharing options...
medic7103 Posted May 14, 2009 Share Posted May 14, 2009 Excellent work! Thanks you! I've just one problem though. When i run the module in a left or right position it displays everything fine. However when I place it in an article it displays my packages but no amounts! Any tips? 0 Quote Link to comment Share on other sites More sharing options...
anderssk Posted May 28, 2009 Share Posted May 28, 2009 Nice tread! How do I include the new currency option for showing prices in the list? 0 Quote Link to comment Share on other sites More sharing options...
hiddenko Posted June 2, 2009 Share Posted June 2, 2009 hi. try this sql request: 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' You will an array with product name, description, prices for billing cycle and currency ISO code Hope this help. 0 Quote Link to comment Share on other sites More sharing options...
anderssk Posted June 2, 2009 Share Posted June 2, 2009 That helps alot! Thx 0 Quote Link to comment Share on other sites More sharing options...
cobrax Posted October 12, 2009 Share Posted October 12, 2009 hi.try this sql request: 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' You will an array with product name, description, prices for billing cycle and currency ISO code Hope this help. Hi i want somthing like this as output in php ore html for my website or a hosting package exelsheet with prices if posible becouse i have a lot of types of servers it is verry long work to make it al custom in a sheet so this php of above is a start but not anough so who can help me out???? 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted October 21, 2009 Share Posted October 21, 2009 i have added the right password but i get this error Access denied for user 'hotel24_whmsold'@'localhost' to database 'hotel24_whmsold' all over my joomla site, my joomla site stoped working when i add the code. any ideas why? 0 Quote Link to comment Share on other sites More sharing options...
Stormgod Posted November 7, 2009 Share Posted November 7, 2009 how would i change this code to display left to right (like "http://hummingbirdhosting.com/hosting.php" ) instead of top to bottom ?? anyone know ? -S 0 Quote Link to comment Share on other sites More sharing options...
Stormgod Posted November 12, 2009 Share Posted November 12, 2009 anyone have any thoughts on this? 0 Quote Link to comment Share on other sites More sharing options...
franscom Posted November 13, 2009 Share Posted November 13, 2009 Hi All. After 2 days of working. searching the internet, and reading in a book called "PHP and MySQL for dummy's" i have figure it out how you can show your domain price list into joomla. First of al instal the mod. Then use this PHP code Registratie prijs per jaar. <?php mysql_connect("localhost", "database_gebuiker", "wachtwoord") or die(mysql_error()); mysql_select_db("database_naam") or die(mysql_error()); $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>Extentie</th> <th><left>Kosten</th> </tr>"; while($row = mysql_fetch_array($result)){ echo "<tr><td>"; echo $row['extension']; echo "</td><td><left>"; echo "€ "; echo $row['msetupfee']; echo "</td></tr>"; } echo "</table>"; ?> Good luck 0 Quote Link to comment Share on other sites More sharing options...
rudberg Posted November 22, 2009 Share Posted November 22, 2009 Franscom: Thanks, will try. Cobrax: Have you checked out Sparky's Mods (linked to under your WHMCS.COM client area. His price comparison mod for hosting works great under the same install as your own WHMCS. 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.