aquiss Posted April 15, 2019 Share Posted April 15, 2019 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. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 15, 2019 Share Posted April 15, 2019 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.. domain_pricing_sort.php 1 Quote Link to comment Share on other sites More sharing options...
aquiss Posted April 16, 2019 Author Share Posted April 16, 2019 Thanks Brian! This works perfect on the client side. Any ideas to make the Admin side more useable? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 16, 2019 Share Posted April 16, 2019 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... backup your database (or at least the tbldomainpricing table) before running the update query... better safe than sorry! ⚠️ 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... 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. 0 Quote Link to comment Share on other sites More sharing options...
aquiss Posted April 16, 2019 Author Share Posted April 16, 2019 lol, you know me too well Brian! Why go half measures, when I can stuff myself up fully LMAO 0 Quote Link to comment Share on other sites More sharing options...
Muhammad Waqas Posted July 16, 2022 Share Posted July 16, 2022 On 16/04/2019 at 4:25 PM, brian! said: SET @counter = -1; UPDATE tbldomainpricing SET tbldomainpricing.order = @counter := @counter + 1 ORDER BY tbldomainpricing.extension ASC; It is a perfect command and it has saved my time a lot. Thanks 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.