Jump to content

Products on index page


inTeL

Recommended Posts

Adam, do you have alittle code that can pull the prices from whmcs database for a html page? I would like to pull my hosting prices. Thanks!

 

Hey,

 

You will need to use PHP to connect to the MySQL database and pull the specific products/services you require.

 

SELECT * FROM tblproducts;

 

The above SQL query would provide you all information (including price) for all products/services you offer.

 

 

I might create a script or post snippets if more people want this...

 

 

Thanks,

Adam

Link to comment
Share on other sites

This should get you started. The database connection should already be open. It pulls the product pricing from the products table. Look at the tblproducts table in the database for other values.

Use {php}...{/php} tags around the code if you want to use it in a template file.

 

 

$query = 'SELECT * FROM tblproducts';

$result = mysql_query ($query);

while ($data = @mysql_fetch_array ($result))

{

$monthly = $data['monthly'];

$quarterly = $data['quarterly'];

$semiannual = $data['semiannual'];

$annual = $data['annual'];

$biennial = $data['biennial'];

$msetupfee = $data['msetupfee'];

$qsetupfee = $data['qsetupfee'];

$ssetupfee = $data['ssetupfee'];

$asetupfee = $data['asetupfee'];

$bsetupfee = $data['bsetupfee'];

 

if ($monthly == '0.00') {$monthly = 'FREE';} else {$monthly = $CONFIG['CurrencySymbol'].$monthly;}

if ($quarterly == '0.00') {$quarterly = 'FREE';} else {$quarterly = $CONFIG['CurrencySymbol'].$quarterly;}

if ($semiannual == '0.00') {$semiannual = 'FREE';} else {$semiannual = $CONFIG['CurrencySymbol'].$semiannual;}

if ($annual == '0.00') {$annual = 'FREE';} else {$annual = $CONFIG['CurrencySymbol'].$annual;}

if ($biennial == '0.00') {$biennial = 'FREE';} else {$biennial = $CONFIG['CurrencySymbol'].$biennial;}

if ($msetupfee == '0.00') {$msetupfee = 'FREE';} else {$msetupfee = $CONFIG['CurrencySymbol'].$msetupfee;}

if ($qsetupfee == '0.00') {$qsetupfee = 'FREE';} else {$qsetupfee = $CONFIG['CurrencySymbol'].$qsetupfee;}

if ($ssetupfee == '0.00') {$ssetupfee = 'FREE';} else {$ssetupfee = $CONFIG['CurrencySymbol'].$ssetupfee;}

if ($asetupfee == '0.00') {$asetupfee = 'FREE';} else {$asetupfee = $CONFIG['CurrencySymbol'].$asetupfee;}

if ($bsetupfee == '0.00') {$bsetupfee = 'FREE';} else {$bsetupfee = $CONFIG['CurrencySymbol'].$bsetupfee;}

}

 

If you have problems I am available for hire.
Link to comment
Share on other sites

Ok, so far so good but I have a question.

 

How do I can the code to display items like this:

 

Plan 1 | Plan 2 | Plan 3 | Plan 4

 

Disk space <<>> Disk space <<>> Disk space <<>> Disk space

Bandwidth <<>> Bandwidth <<>> Bandwidth <<>> Bandwidth

Price <<>> Price <<>> Price <<>> Price

 

 

Retrieving the Disk Space, Bandwidth and Price for each plan. Thanks!

Link to comment
Share on other sites

Thanks Adam I got the prices to show but I would like some of the other fields to show also using configoption1, configoption2 etc fields, I just don't know how to do it.

 

This is what I used to get the prices but I created a file for each package:

 

  if ($package == '1')  echo ("$monthly") ;

Link to comment
Share on other sites

This is what I have used in my site on my hosting.php page

 

Put it in your custom php file and then in the template that your php file is calling use for example

{$plan2_WebSpaceQuota}
To get all the variables assigned put {debug} in your template page somewhere.

 

while ($data = @mysql_fetch_array ($result))

{

$id = $data['id'];

assign('plan'.$id , $data['name']);

$smartyvalues['plan'.$id.'_description'] = $data['description'];

$smartyvalues['plan'.$id.'_hidden'] = $data['hidden'];

$smartyvalues['plan'.$id.'_stockcontrol'] = $data['stockcontrol'];

$smartyvalues['plan'.$id.'_qty'] = $data['qty'];

$smartyvalues['plan'.$id.'_paytype'] = $data['paytype'];

$smartyvalues['plan'.$id.'_subdomain'] = $data['subdomain'];

$smartyvalues['plan'.$id.'_defaultserver'] = $data['defaultserver'];

$smartyvalues['plan'.$id.'_freedomain'] = $data['freedomain'];

$smartyvalues['plan'.$id.'_freedomainpaymentterms'] = $data['freedomainpaymentterms'];

$smartyvalues['plan'.$id.'_freedomaintlds'] = $data['freedomaintlds'];

 

if ($data['servertype'] == 'cpanel')

{

$smartyvalues['plan'.$id.'_Pack'] = $data['configoption1'];

$smartyvalues['plan'.$id.'_FTP'] = $data['configoption2'];

$smartyvalues['plan'.$id.'_WebSpaceQuota'] = $data['configoption3'];

$smartyvalues['plan'.$id.'_Email'] = $data['configoption4'];

$smartyvalues['plan'.$id.'_BandwidthLimit'] = $data['configoption5'];

$smartyvalues['plan'.$id.'_DedicatedIP'] = $data['configoption6'];

$smartyvalues['plan'.$id.'_Shell'] = $data['configoption7'];

$smartyvalues['plan'.$id.'_SQL'] = $data['configoption8'];

$smartyvalues['plan'.$id.'_CGI'] = $data['configoption9'];

$smartyvalues['plan'.$id.'_Subdomains'] = $data['configoption10'];

$smartyvalues['plan'.$id.'_Frontpage'] = $data['configoption11'];

$smartyvalues['plan'.$id.'_MaxParkedDomains'] = $data['configoption12'];

$smartyvalues['plan'.$id.'_cPanelTheme'] = $data['configoption13'];

$smartyvalues['plan'.$id.'_AddonDomains'] = $data['configoption14'];

$smartyvalues['plan'.$id.'_LimitResellerbyNumber'] = $data['configoption15'];

$smartyvalues['plan'.$id.'_LimitResellerbyUsage'] = $data['configoption16'];

$smartyvalues['plan'.$id.'_DiskSpace'] = $data['configoption17'];

$smartyvalues['plan'.$id.'_Bandwidth'] = $data['configoption18'];

$smartyvalues['plan'.$id.'_AllowDSOverselling'] = $data['configoption19'];

$smartyvalues['plan'.$id.'_AllowBWOverselling'] = $data['configoption20'];

$smartyvalues['plan'.$id.'_ResellerACLList'] = $data['configoption21'];

}

 

if ($data['servertype'] == 'hypervm')

{

$smartyvalues['plan'.$id.'_Type'] = $data['configoption1'];

$smartyvalues['plan'.$id.'_PlanName'] = $data['configoption2'];

$smartyvalues['plan'.$id.'_OSTemplate'] = $data['configoption3'];

$smartyvalues['plan'.$id.'_Server'] = $data['configoption4'];

$smartyvalues['plan'.$id.'_NumberOfIPs'] = $data['configoption5'];

}

 

if ($data['servertype'] == 'dotnetpanel')

{

$smartyvalues['plan'.$id.'_PackageName'] = $data['configoption1'];

$smartyvalues['plan'.$id.'_WebSpaceQuota'] = $data['configoption2'];

$smartyvalues['plan'.$id.'_BandwidthLimit'] = $data['configoption3'];

$smartyvalues['plan'.$id.'_PlanID'] = $data['configoption4'];

$smartyvalues['plan'.$id.'_ParentSpaceId'] = $data['configoption5'];

$smartyvalues['plan'.$id.'_EnterpriseServerPort'] = $data['configoption6'];

$smartyvalues['plan'.$id.'_DifferentPotalURL'] = $data['configoption7'];

$smartyvalues['plan'.$id.'_PortalURL'] = $data['configoption8'];

$smartyvalues['plan'.$id.'_SendDNPAccountSummaryemail'] = $data['configoption9'];

$smartyvalues['plan'.$id.'_SendDNPHostingSpaceSummaryemail'] = $data['configoption10'];

$smartyvalues['plan'.$id.'_CreateMailaccount'] = $data['configoption11'];

$smartyvalues['plan'.$id.'_CreateFTPaccount'] = $data['configoption12'];

$smartyvalues['plan'.$id.'_Temporarydomain'] = $data['configoption13'];

$smartyvalues['plan'.$id.'_HTMLemail'] = $data['configoption14'];

$smartyvalues['plan'.$id.'_CreateWebsite'] = $data['configoption15'];

}

 

if ($data['servertype'] == 'enomssl')

{

$smartyvalues['plan'.$id.'_CertificateType'] = $data['configoption3'];

$smartyvalues['plan'.$id.'_Years'] = $data['configoption4'];

}

 

if ($data['servertype'] == 'tcadmin')

{

$smartyvalues['plan'.$id.'_GameID'] = $data['configoption1'];

$smartyvalues['plan'.$id.'_GameSlots'] = $data['configoption2'];

$smartyvalues['plan'.$id.'_GamePrivate'] = $data['configoption3'];

$smartyvalues['plan'.$id.'_GameAdditionalSlots'] = $data['configoption4'];

$smartyvalues['plan'.$id.'_GameIsBranded'] = $data['configoption5'];

$smartyvalues['plan'.$id.'_AdditionalArguments'] = $data['configoption6'];

$smartyvalues['plan'.$id.'_VoiceID'] = $data['configoption7'];

$smartyvalues['plan'.$id.'_VoiceSlots'] = $data['configoption8'];

$smartyvalues['plan'.$id.'_VoicePrivate'] = $data['configoption9'];

$smartyvalues['plan'.$id.'_VoiceAdditionalSlots'] = $data['configoption10'];

$smartyvalues['plan'.$id.'_GameDatacenter'] = $data['configoption11'];

}

 

if ($data['servertype'] == 'whmsonic')

{

$smartyvalues['plan'.$id.'_OS'] = $data['configoption1'];

$smartyvalues['plan'.$id.'_DonotsetupradiogiveaccessviacPanel'] = $data['configoption2'];

$smartyvalues['plan'.$id.'_MaxListenerLimit'] = $data['configoption3'];

$smartyvalues['plan'.$id.'_UseFreePort'] = $data['configoption4'];

$smartyvalues['plan'.$id.'_ServerIP'] = $data['configoption5'];

$smartyvalues['plan'.$id.'_UsersWHMSonicAccessviacPanel'] = $data['configoption6'];

$smartyvalues['plan'.$id.'_MaxBitRate'] = $data['configoption7'];

$smartyvalues['plan'.$id.'_AutoDJFeature'] = $data['configoption8'];

$smartyvalues['plan'.$id.'_WHMPackageName'] = $data['configoption9'];

$smartyvalues['plan'.$id.'_BitRateAbuse'] = $data['configoption10'];

$smartyvalues['plan'.$id.'_BandwidthLimit'] = $data['configoption11'];

}

 

if ($data['servertype'] == 'centovacast')

{

$smartyvalues['plan'.$id.'_URLtoCentovaCast'] = $data['configoption1'];

$smartyvalues['plan'.$id.'_Maxlisteners'] = $data['configoption2'];

$smartyvalues['plan'.$id.'_Maxbitrate'] = $data['configoption3'];

$smartyvalues['plan'.$id.'_Datatransferlimit'] = $data['configoption4'];

$smartyvalues['plan'.$id.'_Diskquota'] = $data['configoption5'];

$smartyvalues['plan'.$id.'_Server-sidesource'] = $data['configoption6'];

$smartyvalues['plan'.$id.'_Startserver'] = $data['configoption7'];

}

 

if ($data['servertype'] == 'scpanel')

{

$smartyvalues['plan'.$id.'_OS'] = $data['configoption3'];

$smartyvalues['plan'.$id.'_MaxUsers'] = $data['configoption4'];

$smartyvalues['plan'.$id.'_NextPort'] = $data['configoption5'];

$smartyvalues['plan'.$id.'_MaxTraffic'] = $data['configoption6'];

$smartyvalues['plan'.$id.'_TrafficAbuse'] = $data['configoption7'];

$smartyvalues['plan'.$id.'_MaxBitRate'] = $data['configoption8'];

$smartyvalues['plan'.$id.'_BitRateAbuse'] = $data['configoption9'];

$smartyvalues['plan'.$id.'_OnDemand'] = $data['configoption10'];

$smartyvalues['plan'.$id.'_Proxy'] = $data['configoption11'];

$smartyvalues['plan'.$id.'_WHMPackageName'] = $data['configoption12'];

$smartyvalues['plan'.$id.'_IntroBackupMaxSize'] = $data['configoption13'];

$smartyvalues['plan'.$id.'_OnDemandMaxSize'] = $data['configoption14'];

$smartyvalues['plan'.$id.'_UsePortPrefixDomain'] = $data['configoption15'];

}

 

if ($data['servertype'] == 'castcontrol')

{

$smartyvalues['plan'.$id.'_Auth'] = $data['configoption3'];

$smartyvalues['plan'.$id.'_Host'] = $data['configoption4'];

$smartyvalues['plan'.$id.'_Path'] = $data['configoption5'];

$smartyvalues['plan'.$id.'_Port'] = $data['configoption6'];

$smartyvalues['plan'.$id.'_MaxUsers'] = $data['configoption7'];

$smartyvalues['plan'.$id.'_MaxBitRate'] = $data['configoption8'];

$smartyvalues['plan'.$id.'_Bandwidth'] = $data['configoption9'];

$smartyvalues['plan'.$id.'_AutoDJ'] = $data['configoption10'];

$smartyvalues['plan'.$id.'_AutoDJQuota'] = $data['configoption11'];

$smartyvalues['plan'.$id.'_SystemID'] = $data['configoption12'];

}

 

 

$monthly = $data['monthly'];

$quarterly = $data['quarterly'];

$semiannual = $data['semiannual'];

$annual = $data['annual'];

$biennial = $data['biennial'];

$msetupfee = $data['msetupfee'];

$qsetupfee = $data['qsetupfee'];

$ssetupfee = $data['ssetupfee'];

$asetupfee = $data['asetupfee'];

$bsetupfee = $data['bsetupfee'];

 

if ($monthly == '0.00') {$monthly = 'FREE';} else {$monthly = $CONFIG['CurrencySymbol'].$monthly;}

if ($quarterly == '0.00') {$quarterly = 'FREE';} else {$quarterly = $CONFIG['CurrencySymbol'].$quarterly;}

if ($semiannual == '0.00') {$semiannual = 'FREE';} else {$semiannual = $CONFIG['CurrencySymbol'].$semiannual;}

if ($annual == '0.00') {$annual = 'FREE';} else {$annual = $CONFIG['CurrencySymbol'].$annual;}

if ($biennial == '0.00') {$biennial = 'FREE';} else {$biennial = $CONFIG['CurrencySymbol'].$biennial;}

if ($msetupfee == '0.00') {$msetupfee = 'FREE';} else {$msetupfee = $CONFIG['CurrencySymbol'].$msetupfee;}

if ($qsetupfee == '0.00') {$qsetupfee = 'FREE';} else {$qsetupfee = $CONFIG['CurrencySymbol'].$qsetupfee;}

if ($ssetupfee == '0.00') {$ssetupfee = 'FREE';} else {$ssetupfee = $CONFIG['CurrencySymbol'].$ssetupfee;}

if ($asetupfee == '0.00') {$asetupfee = 'FREE';} else {$asetupfee = $CONFIG['CurrencySymbol'].$asetupfee;}

if ($bsetupfee == '0.00') {$bsetupfee = 'FREE';} else {$bsetupfee = $CONFIG['CurrencySymbol'].$bsetupfee;}

 

$smartyvalues['plan'.$id.'_monthly'] = $monthly;

$smartyvalues['plan'.$id.'_quarterly'] = $quarterly;

$smartyvalues['plan'.$id.'_semiannual'] = $semiannual;

$smartyvalues['plan'.$id.'_annual'] = $annual;

$smartyvalues['plan'.$id.'_biennial'] = $biennial;

$smartyvalues['plan'.$id.'_msetupfee'] = $msetupfee;

$smartyvalues['plan'.$id.'_qsetupfee'] = $qsetupfee;

$smartyvalues['plan'.$id.'_ssetupfee'] = $ssetupfee;

$smartyvalues['plan'.$id.'_asetupfee'] = $asetupfee;

$smartyvalues['plan'.$id.'_bsetupfee'] = $bsetupfee;

 

}

You can use the hidden variable to not display that section. Example snip of my template file
{if !$plan2_hidden}

<div class="fleft aligncenter" style="width:81px;">

{$plan2_AddonDomains}<br />

{$plan2_MaxParkedDomains}<br />

{$plan2_WebSpaceQuota} MB<br />

{$plan2_BandwidthLimit} MB<br />

{$plan2_Email}<br />

{$plan2_SQL}<br />

{$plan2_FTP}<br />

<a href="cart.php?a=add&pid=2"><img alt="" src="templates/{$template}/images/order_but1.gif" /></a>

</div>

{/if}

I normally charge for this sort of extreme but I must be in a good mood today.

(however donations gracefully accepted via paypal to [billing at tshosting.com.au])

Link to comment
Share on other sites

  if ($package == '1')  echo ("$monthly") ;

 

Hey,

 

Since the SQL statement calls for everything in the DB (*) all the fields listed in tblproducts can be called.

 

echo $data['monthly'];
echo $data['id'];
echo $data['configoption1'];

 

 

Than you do something like

 

if($data['gid'] == 1 && $data['hidden'] != "on" )
{
   echo $data['name'];
   echo "<br />";
   echo $data['description'];
   echo "<br />";
   echo $data['qty'];

}

 

 

Thanks,

Adam

Link to comment
Share on other sites

advanced.php content

 

<?php
    $query = 'SELECT * FROM tblproducts';
    $result = mysql_query ($query);
    while ($data = @mysql_fetch_array ($result))
        {
    $monthly = $data['monthly'];
    $quarterly = $data['quarterly'];
    $semiannual = $data['semiannual'];
    $annual = $data['annual'];
    $biennial = $data['biennial'];
    $msetupfee = $data['msetupfee'];
    $qsetupfee = $data['qsetupfee'];
    $ssetupfee = $data['ssetupfee'];
    $asetupfee = $data['asetupfee'];
    $bsetupfee = $data['bsetupfee'];
   $package = $data['id'];


    if ($monthly == '0.00') {$monthly = 'FREE';} else {$monthly = $CONFIG['CurrencySymbol'].$monthly;}
    if ($quarterly == '0.00') {$quarterly = 'FREE';} else {$quarterly = $CONFIG['CurrencySymbol'].$quarterly;}
    if ($semiannual == '0.00') {$semiannual = 'FREE';} else {$semiannual = $CONFIG['CurrencySymbol'].$semiannual;}
    if ($annual == '0.00') {$annual = 'FREE';} else {$annual = $CONFIG['CurrencySymbol'].$annual;}
    if ($biennial == '0.00') {$biennial = 'FREE';} else {$biennial = $CONFIG['CurrencySymbol'].$biennial;}
    if ($msetupfee == '0.00') {$msetupfee = 'FREE';} else {$msetupfee = $CONFIG['CurrencySymbol'].$msetupfee;}
    if ($qsetupfee == '0.00') {$qsetupfee = 'FREE';} else {$qsetupfee = $CONFIG['CurrencySymbol'].$qsetupfee;}
    if ($ssetupfee == '0.00') {$ssetupfee = 'FREE';} else {$ssetupfee = $CONFIG['CurrencySymbol'].$ssetupfee;}
    if ($asetupfee == '0.00') {$asetupfee = 'FREE';} else {$asetupfee = $CONFIG['CurrencySymbol'].$asetupfee;}
    if ($bsetupfee == '0.00') {$bsetupfee = 'FREE';} else {$bsetupfee = $CONFIG['CurrencySymbol'].$bsetupfee;}




  if ($package == '1')  echo ("$monthly") ;

}
?>

 

I did this for all the other plans by just changing the package number

if ($package == '[color=red][b]1[/b][/color]')  echo ("$monthly") ;

and renaming the advanced.php to say standard.php

 

 

And I included this file into my html file.

 

This works but to add the the different configoptions1,2,3 etc to the same html is where I'm stumped. And your code seems as if I have to put it in a tpl file am I wrong? Thanks!

Link to comment
Share on other sites

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