Jump to content
aquiss

Domain Extension Ordering

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks Brian!

This works perfect on the client side.

Any ideas to make the Admin side more useable?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

lol, you know me too well Brian! Why go half measures, when I can stuff myself up fully LMAO

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

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