Timothé Posted May 21, 2020 Share Posted May 21, 2020 Hello, I am looking for a way to edit a order form to only show sub domain option. What do I have to edit? Thank you in advance Tim 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 22, 2020 Share Posted May 22, 2020 (edited) Hi Tim, 16 hours ago, Timothé said: I am looking for a way to edit a order form to only show sub domain option. What do I have to edit? you shouldn't need to edit any template... so a subdomain option can be enabled on a product-by-product basis... https://docs.whmcs.com/Products_and_Services#Other and then I assume you want to remove the other domain options (reg/trans/own) ? if you don't want to register/tranfser/use existing domains for everything, then you can just disable them in the settings.. https://docs.whmcs.com/Domains_Tab#Domain_Registration_Options ... but that would effectively prevent users from registering or transferring a domain with or without a product - so might not be what you want. you can use hooks to determine which domain option(s) are available with which products... in the example hook above, the specific product can only use a subdomain option, the other options are removed from the cart order form. the hook could be expanded to determine which products are subdomain only, or whatever combination of domain options that you want to assign to each product. Edited May 22, 2020 by brian! 0 Quote Link to comment Share on other sites More sharing options...
Timothé Posted May 22, 2020 Author Share Posted May 22, 2020 Hello, Thank you for the quick answer. I don't have much experience with Hocks, Could you show the code for the example above? Thank you very much. Tim 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 22, 2020 Share Posted May 22, 2020 Hi Tim, 1 minute ago, Timothé said: Could you show the code for the example above? it was in the above thread. 🙂 <?php # Configure Domain Settings For Products # Written by brian! function domain_options_for_products_hook($vars) { $productinfo = $vars['productinfo']; if ($vars['templatefile']=="configureproductdomain") { if ($productinfo['pid'] == "45" && $vars['subdomain']) { return array("registerdomainenabled" => "", "transferdomainenabled" => "", "owndomainenabled" => ""); } } } add_hook("ClientAreaPageCart", 1, "domain_options_for_products_hook"); what you'll have to do is change the product ID value from "45" to whatever the product ID value is that you want a subdomain only option for... get it working for one product first, and then if you need to expand it to multiple products, we'll cross that next bridge. 0 Quote Link to comment Share on other sites More sharing options...
Timothé Posted May 22, 2020 Author Share Posted May 22, 2020 Thank you very much 😀 0 Quote Link to comment Share on other sites More sharing options...
wolverineincaico Posted June 24, 2020 Share Posted June 24, 2020 Hi Folks, Brian, I've created a Hook called (Example: subdomain.php ) Copy Brian's code above with my product Id code #643. When I go to the product link ( https://www.mydomainname.com/whmcs/cart.php?a=add&pid=643 ) It still show the domain registration option with the subdomain. I need to remove the domain option and just keep the subdomain (free hosting) opting to user to fill out. FYI: First time posting (new on the community) Looking forward to hear from you, Thanks, AC 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 26, 2020 Share Posted June 26, 2020 Hi AC, On 24/06/2020 at 21:13, wolverineincaico said: It still show the domain registration option with the subdomain. I need to remove the domain option and just keep the subdomain (free hosting) opting to user to fill out. I think the hook is functioning fine, but there is a block of JS code at the bottom of the configureproductdomain.tpl template that is creating these "Custom Domain"and "Subdomain" options - removing that block of code, should resolve the issue. subdomains can be defined per product in the settings - you don't need to code to create the option. https://docs.whmcs.com/Products_and_Services#Other Quote Subdomain Options — Enter a domain in the format ".yourdomain.com" if you want to offer a free subdomain option for the domain at signup. You can offer more than one by entering a comma separated list (for example, ".yourdomain.com,.yourdomain.net"). 0 Quote Link to comment Share on other sites More sharing options...
Timothé Posted November 19, 2020 Author Share Posted November 19, 2020 On 5/22/2020 at 9:49 AM, brian! said: if you need to expand it to multiple products, we'll cross that next bridge. Hello, It's me again Thank you again for your answer, We would now need to apply "the only sub domain" Hook To multiple products Thank you very much Tim 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted November 19, 2020 Share Posted November 19, 2020 Either make multiple hooks, changing the function name for each, and change the "45" in $productinfo['pid'] == "45" to the proper product id or change the hook to use an array and use in_array to see if the pid is in the array. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 22, 2020 Share Posted November 22, 2020 On 19/11/2020 at 09:50, Timothé said: Thank you again for your answer, We would now need to apply "the only sub domain" Hook if a product is going to use a subdomain option, then you won't need a hook to add it - you can do that via the product setup configuration (other tab -> subdomain options). the only time a hook should be needed would be if a) you needed to make the subdomain the default choice or b) you wanted to remove one or more of the other options. I don't think i'd go down the multiple hook path, i'd decide what needed to occur for each product, see if any of the product choices can be grouped together in an if statement and then code it accordingly. 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.