Jump to content

Show domain pricing in custom website


Recommended Posts

Hello,

I want call domain pricing configured in whmcs in custom website.

But I need to configure php code to show prices when are in promotion or not.

To call individual TLD pricing is:

<script language="javascript" src="feeds/domainprice.php?tld=.com&type=register&regperiod=1&format=1"></script>

 

Anybody can help me what are the variables of specific domains that I need to use to do this code in website:

 

<?php
$com1 = '<script language="javascript" src="feeds/domainprice.php?tld=.com&type=register&regperiod=1&format=1"></script>'
?>

<?php
if ($com1 == 8.50) {
   echo 'price without discount';
} else {
   echo  'price with discount';
}
?>

 

In this way it don't work because it don't compare the numbers...

 

Anybody can help?

Link to comment
Share on other sites

because you're calling &format=1 in your feed URL, the feed will add a currency prefix/suffix in it's output, so you could try the following to not do that and it should work.

 

<?php
$com1 = '<script language="javascript" src="feeds/domainprice.php?tld=.com&type=register&regperiod=1"></script>'
?>

<?php
if ($com1 = 8.50) {
   echo 'price without discount';
} else {
   echo  'price with discount';
}
?>

personally, i'd put all the php in the data feed code, let it create the appropriate output and just add the script link to the feed in your external site - but the above method should work.

Link to comment
Share on other sites

Hello,

Thanks for your reply!

I already try without &format=1 and it don't work, the output say "price with discount" and the prices are the same = 8.50 :S

 

"personally, i'd put all the php in the data feed code, let it create the appropriate output and just add the script link to the feed in your external site"

Do you put what feed code and in what file? Can you explain me? thanks :)

Link to comment
Share on other sites

I already try without &format=1 and it don't work, the output say "price with discount" and the prices are the same = 8.50 :S

I tried it locally before posting and it worked fine for me... if it's not working for you, i'd need to see the website and/or your pricing.

 

Do you put what feed code and in what file? Can you explain me? thanks :)

these Data Feeds can be edited by you or new ones can be created. :idea:

 

http://docs.whmcs.com/Data_Feeds

 

it would be better to modify the data feed code to do the work for you and output what you want, rather than trying to react to the output on your external site.

Link to comment
Share on other sites

My code is:

<?php
$com1 = '<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainprice.php?tld=.com&type=register&regperiod=1"></script>';
$com2 = '<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainprice.php?tld=.com&type=renew&regperiod=1"></script>';
?>
<?php
if ($com1 == $com2) {
   echo 'equal prices';
} else {
   echo  'different prices';
}
?>

<br>

<?php
$biz1 = '<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainprice.php?tld=.biz&type=register&regperiod=1"></script>';
$biz2 = '<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainprice.php?tld=.biz&type=renew&regperiod=1"></script>';
?>
<?php
if ($biz1 == $biz2) {
   echo 'equal prices' ;
} else {
   echo  'different prices' ;
}
?>

 

Unfurtunelly it don't work because the result are always equal in two codes, and the prices are equal in first code (com1 and com2 = 8.50) and in the second code are different (biz1 = 9.70 and biz2 = 5.00)

 

I want only do this code to show prices with discount when they have discount, and not only the price that are in whmcs because with discount I want that it show in red font. What is the best way to do this in all domains?

 

Thanks so much!

Link to comment
Share on other sites

you could tweak that second one to work by doing this...

 

<?php
$register = '<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainprice.php?tld=.biz&type=register&regperiod=1"></script>';
$renew = '<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainprice.php?tld=.biz&type=renew&regperiod=1"></script>';

if ($register < $renew) {
   echo '<strike>'.$renew.'</strike> <font color="red">'.$register.'</font>';
} else {
   echo  $register;
}
?>

or looking at your website, perhaps...

 

<?php
$register = '<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainprice.php?tld=.biz&type=register&regperiod=1"></script>';
$renew = '<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainprice.php?tld=.biz&type=renew&regperiod=1"></script>';

if ($register < $renew) {
   echo '<span class="precovelho">'.$renew.'€</span> <span class="precodesconto"'.$register.'€</span>';
} else {
   echo  $register.'€';
}
?>

for 1 or 2 TLDs this would be fine - if you're thinking of using this in a domain pricing table, it would work... but might be a bit slow.

 

assuming that you're thinking of using this within a domain pricing table - if it were me, i'd suggest that you create a new data feed, based on the domain pricing table feed instead of the above one, and modify it for your needs - it should be quicker to load.

 

<?php

require("../init.php");
require("../includes/domainfunctions.php");

/*
*** USAGE SAMPLES ***

<script language="javascript" src="feeds/domainpricing2.php?currency=1"></script>

*/

$code = '<table cellspacing="1" cellpadding="0" class="domainpricing"><tr><th>TLD</th><th>Min. Years</th><th>Register</th><th>Transfer</th><th>Renew</th></tr>';

if (!is_numeric($currency)) {
   $currency = array();
} else {
   $currency = getCurrency('', $currency);
}

if (!$currency || !is_array($currency) || !isset($currency['id'])) {
   $currency = getCurrency();
}

$freeamt = formatCurrency(0);
$tldslist = getTLDList();
foreach ($tldslist AS $tld) {
   $tldpricing = getTLDPriceList($tld, true);
   $firstoption = current($tldpricing);
   $year = key($tldpricing);
   $transfer = ($firstoption["transfer"] == $freeamt) ? $_LANG['orderfree'] : $firstoption["transfer"];
   if ($firstoption["register"] < $firstoption["renew"]) {
       $code .= sprintf(
       '<tr><td>%s</td><td>%d</td><td><strike>%s</strike> <font color=red>%s</font></td><td>%s</td><td>%s</td></tr>',
       htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),
       $year,
       htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8'),
       htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
       htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
       htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
       );
   } else {
       $code .= sprintf(
       '<tr><td>%s</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td></tr>',
       htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),
       $year,
       htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
       htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
       htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
       );
   }
}

$code .= '</table>';

echo "document.write('".$code."');";

the above will show a table showing either your discounted registration pricing (with renewal price), or if not discounted, just the registration price, for all TLDs.

 

you would call it in your external website using...

 

<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainpricing2.php"></script>

there would be no need for additional PHP coding on your external website - the data feed will do the work for you. :)

 

you will need to replace all the <tr>, <td>, <strike> etc with your own <div> and <span> to match your website design, but the idea will work. :idea:

Link to comment
Share on other sites

Hello Brian and thank so much!

It is exactly what I want!

 

But only other thing...

 

- I want to make some tables to separate and order by country domains and by generic domains... Is it possible to choice what domains in each table?

 

Thanks so much!

Link to comment
Share on other sites

I want to make some tables to separate and order by country domains and by generic domains... Is it possible to choice what domains in each table?

I was hoping you weren't going to ask about doing that! :)

 

if you want to separate them, you'll need to do something like this...

 

<?php

require("../init.php");
require("../includes/domainfunctions.php");

/*
*** USAGE SAMPLES ***

<script language="javascript" src="feeds/domainpricing.php3?table=cctld"></script>

*/

$code = '<table cellspacing="1" cellpadding="0" class="domainpricing"><tr><th>TLD</th><th>Min. Years</th><th>Register</th><th>Transfer</th><th>Renew</th></tr>';

if (!is_numeric($currency)) {
   $currency = array();
} else {
   $currency = getCurrency('', $currency);
}

if (!$currency || !is_array($currency) || !isset($currency['id'])) {
   $currency = getCurrency();
}

$freeamt = formatCurrency(0);
$tldslist = getTLDList();
$tldtable = $whmcs->get_req_var('table');
if ($tldtable == "cctld") {
   $allowedtld = array(".pt", ".us", ".eu", ".bz", ".cc", ".in", ".me", ".mn", ".de", ".co", ".tv", ".es", ".ru");
}
elseif ($tldtable == "gtld") {
   $allowedtld = array(".com", ".com.pt", ".net", ".org", ".biz", ".info", ".asia", ".mobi", ".tv", ".pro", ".name");
}
elseif ($tldtable == "ngtld") {
   $allowedtld = array(".co.uk", ".me.uk", ".org.uk");
}
else {
   $allowedtld = $tldslist;
}
foreach ($tldslist AS $tld) {
   if (in_array($tld, $allowedtld)) {
       $tldpricing = getTLDPriceList($tld, true);
       $firstoption = current($tldpricing);
       $year = key($tldpricing);
       $transfer = ($firstoption["transfer"] == $freeamt) ? $_LANG['orderfree'] : $firstoption["transfer"];
       if ($firstoption["register"] < $firstoption["renew"]) {
           $code .= sprintf(
           '<tr><td>%s</td><td>%d</td><td><strike>%s</strike> <font color=red>%s</font></td><td>%s</td><td>%s</td></tr>',
           htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),
           $year,
           htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
           );
       } else {
           $code .= sprintf(
           '<tr><td>%s</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td></tr>',
           htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),
           $year,
           htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
           );
       }
   }
}

$code .= '</table>';

echo "document.write('".$code."');";

and then to display the cctld table, you would call it like this...

 

<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainpricing3.php?table=cctld"></script>

for the gtld table...

 

<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainpricing3.php?table=gtld"></script>

when you add your NOVAS EXTENSÕES to the third tab, you can display it using...

 

<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainpricing3.php?table=ngtld"></script>

for now, that array just contains the .uk domains you offer, but you can edit these arrays to suit your needs... or add more tables if you need them.

 

if you either don't enter any value, or an invalid value, for "table" in the URL, the data feed will display the entire TLD pricing table.

 

<script language="javascript" src="https://www.lusoaloja.pt/cliente/feeds/domainpricing3.php"></script>

Link to comment
Share on other sites

Hello Brian,

 

Many many thanks!!

But have a problem, because when domain price is 9.99 or 12.99 or 22.50 it don't show price stroke like promotion:

https://www.lusoaloja.pt/cliente/feeds/domainpricing3.php

 

Example of .pt .me .asia ...

Did you know why?

 

Many thanks for your help! It really help so much!

Link to comment
Share on other sites

Did you know why?

yes, because i'm an idiot who shouldn't post code written during a public holiday (as yesterday was here in the UK) :twisted:

 

for some bizarre reason, probably because you were originally asking about the other data feed where we could remove the currency, I hadn't realised the outputted values were strings and not numbers... which is stupidly obvious considering it contains currency symbols ! :roll:

 

*sighs*

 

therefore, we can't compare them in the simple way I previously tried...

 

two alternatives... the simplest way would be to test if the strings are the same - if they are, then the register/renew price is the same, so no strikeout; if different values, use strikeout and red color.

 

if ($firstoption["register"] != $firstoption["renew"]) {

this will work, but doesn't test that the register price is specifically less than the renewal price, so it would strikeout even if the register price was $100 and the renewal price was $50... but if you will never have a register price greater than a renewal price, this won't matter.

 

probably the better way, and this is the one you should try first, will be to remove the currency symbol(s) from the strings and then do the comparison...

 

if (rtrim($firstoption["register"], "€") < rtrim($firstoption["renew"], "€")) {

i'm assuming that your site only uses € at the end of the value (suffix).

 

for anyone else reading this, who adds the currency symbol to the beginning (prefix) of the value (UK, US etc), you would use ltrim instead..

 

if (ltrim($firstoption["register"], "£") < ltrim($firstoption["renew"], "£")) {

and if you used both prefix and suffix, e.g $10.00 USD, you would use trim...

 

if (trim($firstoption["register"], "$ USD") < trim($firstoption["renew"], "$ USD")) {

if the feed needed to work in multiple currencies, then you'd have to adapt it to use the currency values - but you won't need to do that if you're only using one currency... so let's not even think about it! :)

 

testing locally, this works for me - but let me know if it doesn't work for you.

Link to comment
Share on other sites

Hello Brian!

 

Is it possible to put "new" before new domains in table?

 

I don't want make only a table of new extensions, but include any domains in first table per example...

And other question is how to remove "min years" column :D

 

Thanks a lot!

Link to comment
Share on other sites

Hi,

 

i'll do this in reverse order as it's easier - so to get rid of the "min years" column, you'd just need to remove the column heading and then remove the $year value from the output.

 

if I understand correctly what you want to do with new domains, I think you'd just need to create an array of new domains and then check during the output to see if the TLD is in that array.

 

<?php

require("../init.php");
require("../includes/domainfunctions.php");

/*
*** USAGE SAMPLES ***

<script language="javascript" src="feeds/domainpricing.php3?table=cctld"></script>

*/

$code = '<table cellspacing="1" cellpadding="0" class="domainpricing"><tr><th>TLD</th><th>Register</th><th>Transfer</th><th>Renew</th></tr>';

if (!is_numeric($currency)) {
   $currency = array();
} else {
   $currency = getCurrency('', $currency);
}

if (!$currency || !is_array($currency) || !isset($currency['id'])) {
   $currency = getCurrency();
}

$freeamt = formatCurrency(0);
$tldslist = getTLDList();
$tldtable = $whmcs->get_req_var('table');
if ($tldtable == "cctld") {
   $allowedtld = array(".pt", ".us", ".eu", ".bz", ".cc", ".in", ".me", ".mn", ".de", ".co", ".tv", ".es", ".ru");
}
elseif ($tldtable == "gtld") {
   $allowedtld = array(".com", ".com.pt", ".net", ".biz", ".info", ".asia", ".mobi", ".tv", ".pro", ".name");
}
elseif ($tldtable == "ngtld") {
   $allowedtld = array(".co.uk", ".me.uk", ".org.uk");
}
else {
   $allowedtld = $tldslist;
}
$newtlds = array(".co.uk", ".cloud");

foreach ($tldslist AS $tld) {
   if (in_array($tld, $allowedtld)) {
       $tldpricing = getTLDPriceList($tld, true);
       $firstoption = current($tldpricing);
       $year = key($tldpricing);
       $transfer = ($firstoption["transfer"] == $freeamt) ? $_LANG['orderfree'] : $firstoption["transfer"];
       if (in_array($tld, $newtlds)) {
           $tld = "new ".$tld;
       }
       if (rtrim($firstoption["register"], "€") < rtrim($firstoption["renew"], "€")) {  
           $code .= sprintf(
           '<tr><td>%s</td><td><strike>%s</strike> <font color=red>%s</font></td><td>%s</td><td>%s</td></tr>',
           htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
           );
       } else {
           $code .= sprintf(
           '<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
           htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
           htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
           );
       }
   }
}

$code .= '</table>';

echo "document.write('".$code."');";

if you wanted to use an image instead of "new", then you'd need to make other changes to the feed code - but you didn't ask about using images. :)

Link to comment
Share on other sites

Yes, it work fine!

But if I want to put font color in red or with css class don't work to put html in "new ".$tld isn't right?

that's right - you couldn't add html tags in that method... but you didn't say you wanted to either! :)

 

try the following code instead... this will show an image instead of "New" - obviously, don't use someone else's image and bandwidth as I have with this example (found via Google Images), use an icon image on your local server instead. :idea:

 

<?php

require("../init.php");
require("../includes/domainfunctions.php");

/*
*** USAGE SAMPLES ***

<script language="javascript" src="feeds/domainpricing.php3?table=cctld"></script>

*/

$code = '<table cellspacing="1" cellpadding="0" class="domainpricing"><tr><th>TLD</th><th>Register</th><th>Transfer</th><th>Renew</th></tr>';

if (!is_numeric($currency)) {
   $currency = array();
} else {
   $currency = getCurrency('', $currency);
}

if (!$currency || !is_array($currency) || !isset($currency['id'])) {
   $currency = getCurrency();
}

$freeamt = formatCurrency(0);
$tldslist = getTLDList();
$tldtable = $whmcs->get_req_var('table');
if ($tldtable == "cctld") {
   $allowedtld = array(".pt", ".us", ".eu", ".bz", ".cc", ".in", ".me", ".mn", ".de", ".co", ".tv", ".es", ".ru");
}
elseif ($tldtable == "gtld") {
   $allowedtld = array(".com", ".com.pt", ".net", ".biz", ".info", ".asia", ".mobi", ".tv", ".pro", ".name");
}
elseif ($tldtable == "ngtld") {
   $allowedtld = array(".co.uk", ".me.uk", ".org.uk");
}
else {
   $allowedtld = $tldslist;
}
$newtlds = array(".co.uk", ".com");

foreach ($tldslist AS $tld) {
   if (in_array($tld, $allowedtld)) {
       $tldpricing = getTLDPriceList($tld, true);
       $firstoption = current($tldpricing);
       $year = key($tldpricing);
       $transfer = ($firstoption["transfer"] == $freeamt) ? $_LANG['orderfree'] : $firstoption["transfer"];
       $code .= '<tr><td>';
           if (in_array($tld, $newtlds)) {
               $code .= '<img src="http://images.wondershare.com/styles/images/new_23.png">';
           }
       if (rtrim($firstoption["register"], "€") < rtrim($firstoption["renew"], "€")) { 

               $code .= sprintf('%s</td><td><strike>%s</strike> <font color=red>%s</font></td><td>%s</td><td>%s</td></tr>',
               htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
               );
           } else {
               $code .= sprintf('%s</td><td>%s</td><td>%s</td></tr>',
               htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
           );
       }
   }
}

$code .= '</table>';

echo "document.write('".$code."');";

and you'd end up with this...

e7eba6401bf9483da70dc182c2d0e6ed.png

 

you'd have to play with the spacing to make it look right, but you can at least see how it roughly looks. :idea:

 

if you want to change the font color, css styling etc edit..

 

            if (in_array($tld, $newtlds)) {
               $code .= '<img src="http://images.wondershare.com/styles/images/new_23.png">';
           }

to...

 

            if (in_array($tld, $newtlds)) {
               $code .= '<font color=red><sup>New </sup></font>';
           }

and it show as...

44a6eb9722d64523b4c10a3bf9cdb456.png

Link to comment
Share on other sites

Hello Brian and thanks!

 

But there is an error because with this code, isn't showing the renew price in any domains:

https://www.lusoaloja.pt/cliente/feeds/domainpricing2.php

 

It is possible to put image or code on the right of domain?

 

Thanks!

Link to comment
Share on other sites

hmm.. I must have deleted one of the columns when copy & pasting or removing the year column :roll:

 

try replace the else block with this...

 

           } else {
               $code .= sprintf('%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
               htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')

with regards to having the image on the right, you'll basically have to split the sprintf output into 2 parts... do you want to have the image on the right ?

Edited by brian!
Link to comment
Share on other sites

Hello Brian! Thanks a lot...!

 

It is not necessary to put image on the right of domain, just like to see how it looked, but don't worry about it.

 

I'm thinking and I would like to put a tab with promotion domains each month.. There is an automatic way to show domains in promotion in each month or it have to be entered in other table manually?

 

Thanks one more time!!!

Link to comment
Share on other sites

Hello Brian! Thanks a lot...!

 

It is not necessary to put image on the right of domain, just like to see how it looked, but don't worry about it.

it's not difficult to do, you just need to alter the output slightly...

 

<?php

require("../init.php");
require("../includes/domainfunctions.php");

/*
*** USAGE SAMPLES ***

<script language="javascript" src="feeds/domainpricing.php5?table=cctld"></script>

*/

$code = '<table cellspacing="1" cellpadding="0" class="domainpricing"><tr><th>TLD</th><th>Register</th><th>Transfer</th><th>Renew</th></tr>';

if (!is_numeric($currency)) {
   $currency = array();
} else {
   $currency = getCurrency('', $currency);
}

if (!$currency || !is_array($currency) || !isset($currency['id'])) {
   $currency = getCurrency();
}

$freeamt = formatCurrency(0);
$tldslist = getTLDList();
$tldtable = $whmcs->get_req_var('table');
if ($tldtable == "cctld") {
   $allowedtld = array(".pt", ".us", ".eu", ".bz", ".cc", ".in", ".me", ".mn", ".de", ".co", ".tv", ".es", ".ru");
}
elseif ($tldtable == "gtld") {
   $allowedtld = array(".com", ".com.pt", ".net", ".biz", ".info", ".asia", ".mobi", ".tv", ".pro", ".name");
}
elseif ($tldtable == "ngtld") {
   $allowedtld = array(".co.uk", ".me.uk", ".org.uk");
}
else {
   $allowedtld = $tldslist;
}
$newtlds = array(".co.uk", ".com", ".org.uk");

foreach ($tldslist AS $tld) {
   if (in_array($tld, $allowedtld)) {
       $tldpricing = getTLDPriceList($tld, true);
       $firstoption = current($tldpricing);
       $year = key($tldpricing);
       $transfer = ($firstoption["transfer"] == $freeamt) ? $_LANG['orderfree'] : $firstoption["transfer"];
       $code .= sprintf('<tr><td>%s',
               htmlspecialchars($tld, ENT_QUOTES, 'UTF-8')
               );
           if (in_array($tld, $newtlds)) {
               $code .= ' <img src="http://images.wondershare.com/styles/images/new_23.png">';
           }
           if (rtrim($firstoption["register"], "€") < rtrim($firstoption["renew"], "€")) {  
               $code .= sprintf('</td><td><strike>%s</strike> <font color=red>%s</font></td>',                
               htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8')
               );
           } else {
               $code .= sprintf('</td><td>%s</td>',
               htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8')
               );
           }
       $code .= sprintf('<td>%s</td><td>%s</td></tr>',
               htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
           );        
   }
}

$code .= '</table>';

echo "document.write('".$code."');";

it should look similar to this...

 

3def1df7c8a14740a2b3ec9b5f5fa51b.png

 

in the above code, i've added a space before the icon, but you can achieve the same by using CSS instead.

 

I'm thinking and I would like to put a tab with promotion domains each month.. There is an automatic way to show domains in promotion in each month or it have to be entered in other table manually?

it can be done automatically, but the easiest way would be to use a separate data feed - you could modify the above feed to do it, but it's simpler to just use a basic version of the above feed... i've called it domainpricingpromo.php - but you can call it anything...

 

<?php

require("../init.php");
require("../includes/domainfunctions.php");

/*
*** USAGE SAMPLES ***

<script language="javascript" src="feeds/domainpricingpromo.php"></script>

*/

$code = '<table cellspacing="1" cellpadding="0" class="domainpricing"><tr><th>TLD</th><th>Register</th><th>Transfer</th><th>Renew</th></tr>';

if (!is_numeric($currency)) {
   $currency = array();
} else {
   $currency = getCurrency('', $currency);
}

if (!$currency || !is_array($currency) || !isset($currency['id'])) {
   $currency = getCurrency();
}

$freeamt = formatCurrency(0);
$tldslist = getTLDList();
$tldtable = $whmcs->get_req_var('table');

foreach ($tldslist AS $tld) {
       $tldpricing = getTLDPriceList($tld, true);
       $firstoption = current($tldpricing);
       $year = key($tldpricing);
       $transfer = ($firstoption["transfer"] == $freeamt) ? $_LANG['orderfree'] : $firstoption["transfer"];
       if (rtrim($firstoption["register"], "€") < rtrim($firstoption["renew"], "€")) {   
               $code .= sprintf('<tr><td>%s</td><td><strike>%s</strike> <font color=red>%s</font></td><td>%s</td><td>%s</td></tr>',
               htmlspecialchars($tld, ENT_QUOTES, 'UTF-8'),            
               htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["register"], ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($transfer, ENT_QUOTES, 'UTF-8'),
               htmlspecialchars($firstoption["renew"], ENT_QUOTES, 'UTF-8')
               );
       }
}

$code .= '</table>';

echo "document.write('".$code."');";

to keep it simpler, i've not added any "New" logos to this - but as per the first feed, they can be added by splitting the sprintf output.

Link to comment
Share on other sites

  • 4 months later...
Is it possible to sort the domains into alphabetical order?

easily - after the $tldslist = getTLDList(); line of code, you just need to use the PHP array sort functions to rearrange the array. :idea:

 

if you want the TLDs shown A-Z...

$tldslist = getTLDList();
asort($tldslist);

or if you want them Z-A...

 

$tldslist = getTLDList();
arsort($tldslist);

Link to comment
Share on other sites

Hi,

 

I have a couple of small issues.

 

My pricing table shows the prices with the £ sign as well as GBP. I would like to remove the GBP. Is this possible?

 

Also, when there are domains with discounted register prices, the strike-through and red is only applied on a couple of the domains. There are several where the formatting is not applied.

 

[TABLE=class: domainpricing]

[TR]

[TH]TLD[/TH]

[TH]Register[/TH]

[TH]Transfer[/TH]

[TH]Renew[/TH]

[/TR]

[TR]

[TD].cloud[/TD]

[TD]£24.08GBP

[/TD]

[TD]£24.08GBP[/TD]

[TD]£24.08GBP[/TD]

[/TR]

[TR]

[TD].club[/TD]

[TD]£16.47GBP £1.91GBP

[/TD]

[TD]£16.47GBP[/TD]

[TD]£16.47GBP[/TD]

[/TR]

[TR]

[TD].co[/TD]

[TD]£25.83GBP £10.31GBP

[/TD]

[TD]£25.83GBP[/TD]

[TD]£25.83GBP[/TD]

[/TR]

[TR]

[TD].biz[/TD]

[TD]£4.70GBP[/TD]

[TD]£12.63GBP[/TD]

[TD]£12.63GBP[/TD]

[/TR]

[TR]

[TD].eu[/TD]

[TD]£3.95GBP[/TD]

[TD]£10.50GBP[/TD]

[TD]£10.50GBP[/TD]

[/TR]

[/TABLE]

 

I have tried changing the register prices on these domains at some prices the formatting works and others it doesn't.

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