Jump to content
Craft

How to merge the 2 text fields of the domain name + TLD?

Recommended Posts

How to merge the 2 text fields of the domain name + TLD while purchasing a new web hosting package with an existing domain name?

To allow the customers to write their existing domain at one text field only.

 

Existing Domain.png

Share this post


Link to post
Share on other sites

Can't out of the box.  WHMCS expects them to be separate and so at the end they need to be separate for it to work.  You could use a hook that injects javascript that hides those two fields, puts a single field in its place, and on form submit separates them via the periods but would need determine between a .com and a .com.co  or other such *TLDs.  

Share this post


Link to post
Share on other sites
51 minutes ago, steven99 said:

Can't out of the box.  WHMCS expects them to be separate and so at the end they need to be separate for it to work.  You could use a hook that injects javascript that hides those two fields, puts a single field in its place, and on form submit separates them via the periods but would need determine between a .com and a .com.co  or other such *TLDs.  

Do you know how to create this hook?

Share this post


Link to post
Share on other sites
15 hours ago, Craft said:

Could you please take a look at this topic? 🙂

you assumed that I didn't already - I read *everything*. 🙂

I didn't bother replying because I agreed with steven99's reply and his explanation as to the solution.... it seemed pretty redundant to just agree for the sake of it... although I can think of one staff member here that has (had) a habit of doing that.  😜

Share this post


Link to post
Share on other sites
On 11/16/2020 at 5:31 PM, Craft said:

Do you know how to create this hook?

Yup, I do. 😉 Oh you want instructions / the hook?   A bit pressed for time so can't give a whole tested solution.

Basically the hook would look like:
 

add_hook('ClientAreaHeadOutput', 1, function($vars) {

   $JS =  "<script> $( document ).ready(function() {
            $('#inputnewDomain').hide();
            $('#inputnewDomainTLD').hide();
            $('#inputnewDomain').parent().append(\"<input name='domainnamesidtld' id='domainnamesidtld'>\");
            $( '#domainnamesidtld' ).keyup(function() { $( '#inputnewDomain' ).val($( '#domainnamesidtld' ).val() ) });
            
            });
 </script> ";
 return $JS;
};

You'll need to find the correct IDs for the 'inputnewDomainTLD' and "inputnewDomainTLD"  and change as needed.  You'll also need javascript to split the domain part (sid) from the TLD and have something to check for multiple level TLDs like .com.za/au/whatever .  Place within a file called domainSIDTLDcombined.php or whatever name you want and place that within /WHMCS/includes/hooks/  . 

With that said, personally I think it is better to have a menu for the TLD as then they can have a list of all TLDs you support as well as it prevents mistakes that can be frustrating to clients. 

Share this post


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