Jump to content

Sharing a Customization that reorders the Client Products/Services Dropdown Menu


smplejohn

Recommended Posts

Like the title says, I got tired of seeing Active and Non-Active products mixed in with each other, so this small hook reorders the dropdown into the <optgroup> tag for Active and Non-Active Products. Here's what it'll look like:

 

product-separating.png

 

And... here's the code for the hook:

 

<?php

 add_hook('AdminAreaFooterOutput', 1, function($vars) {
   if ($vars['filename'] == 'clientsservices'){
     return "

       <script>
         $(document).ready(function(){
           var active;
           var nonactive;
           var i = 0;
           var total = $('#frm2 select[name=id] option').length;
           $('#frm2 select[name=id] option').each(function(){
             if ($(this).attr('style').indexOf('#FFF') > 0) {
               active = active + $(this).context.outerHTML;
             } else {
               nonactive = nonactive + $(this).context.outerHTML;
             }
             i++;
             if (i == total) {
               $('#frm2 select[name=id]').html(\"<optgroup label='Active'>\" + active + \"</optgroup><optgroup label='Non-Active'>\" + nonactive + \"</optgroup>\");
             }
           });
         });
       </script>

     ";
   }
 });

 

I created a new file under /includes/hooks/hook_betterClientProducts.php

 

Enjoy :)

Link to comment
Share on other sites

which version of WHMCS is this supposed to be for ?

if I try it on v6.2.2, I see that it doesn't split the products correctly between active and non-active...

 

Px5YEXQ.png

 

if I try it in v.7.2.2, I don't see anything new in the dropdown output - neither "Active" or "Non-Active" are added to the dropdown.... I can see the JS code in the page source, so the hook is being triggered, it just doesn't work. :?:

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