Jump to content

Removing domain order/transfer/use from cart, allow only subdomain


Recommended Posts

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.

PXVw5Nh.png

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 by brian!
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...

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

 

Link to comment
Share on other sites

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").

Link to comment
Share on other sites

  • 4 months later...
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

Link to comment
Share on other sites

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.

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.

×
×
  • 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