Jump to content

Display Price List in Joomla


Recommended Posts

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!

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

  • 4 months later...

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

Link to comment
Share on other sites

  • 4 weeks later...

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

Link to comment
Share on other sites

  • 3 months later...

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

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

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.

Link to comment
Share on other sites

  • 4 months later...
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????

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

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

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated