Jump to content

Domain Extension Ordering


aquiss

Recommended Posts

Does anyone know of quick way of ordering domain extensions in the pricing tables in alphabetical order?

Yes, we can drag the extensions into a logical order, which was quite a practical way when they was first developed back in earlier releases of WHMCS, however, with a growing list of extensions now available, this is somewhat slow and impractical.

Link to comment
Share on other sites

one option would be to sort the $pricing array by key in an action hook...

<?php

/**
* Domain Pricing TLD Sort Hook
* @author Brian!
*/

function domain_pricing_matrix_TLD_sort_hook($vars)
{
	if ($vars['templatefile']=='domainregister'){
		$pricing = $vars['pricing'];
		$tld = $pricing['pricing'];
		ksort($tld);
		$pricing['pricing'] = $tld;
		return array("pricing" => $pricing);
	}
	if ($vars['templatefile']=='domain-pricing'){
		$pricing = $vars['pricing'];
		ksort($pricing);
		return array("pricing" => $pricing);
	}
}
add_hook("ClientAreaPage", 1, "domain_pricing_matrix_TLD_sort_hook"); 

first part deals with the Pricing Matrix Table on the domain registration page, second part deals with the separate domain pricing page..

CwY2wsI.png

domain_pricing_sort.php

Link to comment
Share on other sites

25 minutes ago, aquiss said:

Any ideas to make the Admin side more useable?

I had a feeling after I posted that hook last night, you were going to want something on the admin side too/instead! 🙂

using a SQL update query, you could re-sort the tbldomainpricing table order column as that table has it's own sort order value (which is what the client area must use to generate the order on the domain registration $pricing arrays).

SET @counter = -1;
UPDATE tbldomainpricing SET tbldomainpricing.order = @counter := @counter + 1
ORDER BY tbldomainpricing.extension ASC;

usual two warnings with this...

  1. backup your database (or at least the tbldomainpricing table) before running the update query... better safe than sorry! ⚠️
  2. this will change the sort order of the table - once changed, there's no undo option! (short of restoring the backup).

once the table has been resorted, then the TLDs will be shown in that order on the domain pricing page in the admin area...

o85Obbp.png

with this query, you will have the option of running it after you add a new TLD to domain pricing and the list will be sorted alphabetically again.

this probably goes without saying, but i'm going to say it anyway - if you're going to run this query on the admin side, then the previous client area hook will be redundant as the database table has already been been resorted.

Link to comment
Share on other sites

  • 3 years 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