tsiedsma Posted January 7, 2011 Share Posted January 7, 2011 I have noticed an increase in orders with upper case letters in domain names like this: ThisTypeOFDomain.com Why is this a problem you ask? Well, WHMCS does not force it to be lower case, this results in the username for cPanel to be uppercase and lowercase. cPanel runs on Linux which is case sensitive. Also, domains are all lower case, so why not just force it from the start? Here is my solution. I have made a couple of assumptions here, you need to have jQuery and the order form is the first form on your page. If you have any other forms that exist on your page, there are ways to make this work easier. Paste this code at the very top of configureproductdomain.tpl in your whmcs/templates/orderforms/template folder {literal} <script type="text/javascript"> $(function() { $('form:first').submit(function() { $('input[type=text]').each(function() { $(this).val($(this).val().toLowerCase()); }); }); }); </script> {/literal} You can edit your template file and give your form an id like this: <form method="post" action="{$smarty.server.PHP_SELF}?a=add&pid={$pid}" id="configProductForm"> Then edit the jquery code above and change the following: $('form:first').submit(function() { to $('#configProductForm').submit(function() { This will ensure the submit function is bound to the proper form. What does this do? When the user types in UpPeRCase letters into the domain fields, as soon as the form is submitted they are changed to lower case. This will be evident on the following pages. Post here if you have any issues or questions! Mod, can you move this to the How To's forum? I couldn't post a new thread! 0 Quote Link to comment Share on other sites More sharing options...
GORF Posted January 7, 2011 Share Posted January 7, 2011 Thank you for taking the time to work out a "patch" for this problem and post it for all of us. This has been mentioned a few times here and I hope it will be addressed soon. 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted January 7, 2011 Author Share Posted January 7, 2011 I will likely come up with a HOOK to fix this too. Then it is forced on the back end and the customer can't get around it. The other problem with jQuery is it requires javascript to be enabled on the customer's computer which we have no control over. 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted January 8, 2011 Share Posted January 8, 2011 I will likely come up with a HOOK to fix this too. Then it is forced on the back end and the customer can't get around it. The other problem with jQuery is it requires javascript to be enabled on the customer's computer which we have no control over. congrats on looking for a solution - and yes, doing it by hook in your code, rather than javascript in the client-browser would be a better option. 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted January 8, 2011 Author Share Posted January 8, 2011 I just whipped this up and tested it myself. Create a new file in whmcs/includes/hooks/ and call it whatever you want, or add this code to a file in that folder. function lowercase_domain_hook($vars) { if (is_array($vars['products'])) { foreach($vars['products'] AS $k => $v) { if (isset($_SESSION['cart']['products'][$k]['domain'])) { $_SESSION['cart']['products'][$k]['domain'] = strtolower($v['domain']); } } } if (is_array($vars['domains'])) { foreach($vars['domains'] AS $k => $v) { if (isset($_SESSION['cart']['domains'][$k]['domain'])) { $_SESSION['cart']['domains'][$k]['domain'] = strtolower($v['domain']); } } } } add_hook("PreCalculateCartTotals",1,"lowercase_domain_hook"); 0 Quote Link to comment Share on other sites More sharing options...
alinford Posted January 8, 2011 Share Posted January 8, 2011 (edited) This worked nicely. Thanks Edited January 8, 2011 by alinford 0 Quote Link to comment Share on other sites More sharing options...
dinocol Posted January 15, 2012 Share Posted January 15, 2012 I've copied the hook to includes/hooks but it doesn't seem to work. Any help would be appreciated. 0 Quote Link to comment Share on other sites More sharing options...
m8internet Posted January 15, 2012 Share Posted January 15, 2012 I don't appear to have anything in place Tested various Domain Names, mix of capitals and lower case, all are converted to lower case Equally, I've not noticed any in such a combination, all are lower case Looks like something was changed for v5.x.x 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted January 15, 2012 Author Share Posted January 15, 2012 I think 5 forces lower case domain names now so that hook isn't necessary. 0 Quote Link to comment Share on other sites More sharing options...
m8internet Posted January 15, 2012 Share Posted January 15, 2012 Just an aside, it may be Ordering template related I am using Vertical Steps 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.