WHMCS fix for namespinner – PHP / Smarty

WHMCS is a great tool for web hosting services (and one of my favorite web hosting companies, Immortal Design uses it, too.) There are some kinks to WHMCS, as with any program, but it is constantly updated and made better. For those of you using it with eNom as your registrar, there’s a great free code called eNom name spinner. It allows you to provide relevant/similar domain names for both registered and non-registered .com, .net, .cc and .tv domains. The installation is smooth and easy, but when you go and register/try out a name, it sadly shows all the domain names that don’t have a 0 pricing. Which is great, only one problem: WHMCS requires you to put in a -1 to not have the domain registration show up for that domain. How do we fix? Simple.

At about line 133, you get this code:
[code]
while ($row = @mysql_fetch_array ($query, MYSQL_ASSOC)) {
if ($row[‘year1′] != 0) $domainprices[$row[‘extension’]][1] = $row[‘year1′];
if ($row[‘year2′] != 0) $domainprices[$row[‘extension’]][2] = $row[‘year2′];
if ($row[‘year3′] != 0) $domainprices[$row[‘extension’]][3] = $row[‘year3′];
if ($row[‘year4′] != 0) $domainprices[$row[‘extension’]][4] = $row[‘year4′];
if ($row[‘year5′] != 0) $domainprices[$row[‘extension’]][5] = $row[‘year5′];
if ($row[‘year6′] != 0) $domainprices[$row[‘extension’]][6] = $row[‘year6′];
if ($row[‘year7′] != 0) $domainprices[$row[‘extension’]][7] = $row[‘year7′];
if ($row[‘year8′] != 0) $domainprices[$row[‘extension’]][8] = $row[‘year8′];
if ($row[‘year9′] != 0) $domainprices[$row[‘extension’]][9] = $row[‘year9′];
if ($row[‘year10′] != 0) $domainprices[$row[‘extension’]][10] = $row[‘year10′];
}[/code]

Change it to this (you can copy and paste the code below):
[code]
while ($row = @mysql_fetch_array ($query, MYSQL_ASSOC)) {
if (($row[‘year1′] != 0) && ($row[‘year1′] != -1)) $domainprices[$row[‘extension’]][1] = $row[‘year1′];
if (($row[‘year2′] != 0) && ($row[‘year2′] != -1)) $domainprices[$row[‘extension’]][2] = $row[‘year2′];
if (($row[‘year3′] != 0) && ($row[‘year3′] != -1)) $domainprices[$row[‘extension’]][3] = $row[‘year3′];
if (($row[‘year4′] != 0) && ($row[‘year4′] != -1)) $domainprices[$row[‘extension’]][4] = $row[‘year4′];
if (($row[‘year5′] != 0) && ($row[‘year5′] != -1)) $domainprices[$row[‘extension’]][5] = $row[‘year5′];
if (($row[‘year6′] != 0) && ($row[‘year6′] != -1)) $domainprices[$row[‘extension’]][6] = $row[‘year6′];
if (($row[‘year7′] != 0) && ($row[‘year7′] != -1)) $domainprices[$row[‘extension’]][7] = $row[‘year7′];
if (($row[‘year8′] != 0) && ($row[‘year8′] != -1)) $domainprices[$row[‘extension’]][8] = $row[‘year8′];
if (($row[‘year9′] != 0) && ($row[‘year9′] != -1)) $domainprices[$row[‘extension’]][9] = $row[‘year9′];
if (($row[‘year10′] != 0) && ($row[‘year10′] != -1)) $domainprices[$row[‘extension’]][10] = $row[‘year10′];
}
[/code]
The code above fixes the whole -1 issue, so that no domain name with either a 0 or -1 one pricing shows up for registration availability when you suggest new domains. You can check out how this script upgrade works live at ID (input a few domains to see how it works). Awesome, no?

UPDATE: June 02, 2012 – this code may not work as of WHMCS 5, but am not sure. Will definitely test and see.

4 Responses to “WHMCS fix for namespinner – PHP / Smarty

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

pishner89@mailxu.com reutzel.waneta@mailxu.com