PDA

View Full Version : Display Price List in Joomla



jbougeno
06-19-08, 06:23 AM
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!

goddess_dix
06-22-08, 04:07 PM
Thank you for this. I'm betting I could adapt this to display price stuff in a Drupal site as well. :-P

sastrugi
08-06-08, 11:50 PM
Hi,

Can I ask if this is for Joomla v1.0.x or v1.5.x ??

Regards,

Steve

jbougeno
08-07-08, 04:27 AM
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.

sastrugi
08-07-08, 07:21 AM
Many thanks for the info!! :)

goddess_dix
12-30-08, 03:15 AM
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. :-P

markholland8
01-23-09, 10:52 PM
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

Hosteris
04-24-09, 03:45 PM
Hi,
how can I show prices of diferent currency?
eg. productsUSD.html (?currency=1)
productsEUR.html (?currency=2)
(v4.0)

Regards.

jbougeno
04-24-09, 10:25 PM
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

Hosteris
04-26-09, 09:49 PM
Thanks Joe.

working in the solution...

Regards.

Hosteris
04-26-09, 11:47 PM
finally !!

ok, only "hosting and other products", prices of domain in develop, but, thats all for sunday...

*SFMBE

jbougeno
04-26-09, 11:59 PM
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.

medic7103
05-14-09, 09:35 PM
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?

anderssk
05-28-09, 05:23 PM
Nice tread!
How do I include the new currency option for showing prices in the list?

hiddenko
06-02-09, 02:13 PM
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.

anderssk
06-02-09, 08:05 PM
That helps alot! Thx

cobrax
10-12-09, 03:00 PM
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????

andersbirkenstam
10-21-09, 06:28 AM
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?

Stormgod
11-07-09, 02:49 AM
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

Stormgod
11-12-09, 07:15 AM
anyone have any thoughts on this?

franscom
11-13-09, 01:34 PM
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

rudberg
11-22-09, 01:52 PM
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.