Jump to content
luigidefra

Hide "Register a new domain" in each page

Recommended Posts

Hi, In my project I can create a new domain only in bundle with shared hosting, then i need hide Register a new domain on header and left bar, how can i do?

Share this post


Link to post
Share on other sites
On 21/09/2020 at 18:38, luigidefra said:

Hi, In my project I can create a new domain only in bundle with shared hosting, then i need hide Register a new domain on header and left bar, how can i do?

there are multiple ways - depending on how thorough you need to be...

you could use CSS (in custom.css) or hooks to hide the links - though if the user knew the URL to the domain register page, then they could still register domains that way...

#Primary_Navbar-Store-Register_a_New_Domain {display: none;}
#Secondary_Sidebar-Actions-Domain_Registration {display: none;}

another way would be to disable domain registration in the settings (e.g setup -> general settings -> domains -> domain registration options -> untick "Allow clients to register domains with you".

that disables domain registrations on their own and with products too, so then you could write a hook to enable the register domain option on specific products only and then only the products can you list will be able to register domains when ordering - other products, and direct domain registrations will be prevented.

Share this post


Link to post
Share on other sites
21 hours ago, brian! said:

another way would be to disable domain registration in the settings (e.g setup -> general settings -> domains -> domain registration options -> untick "Allow clients to register domains with you".

that disables domain registrations on their own and with products too, so then you could write a hook to enable the register domain option on specific products only and then only the products can you list will be able to register domains when ordering - other products, and direct domain registrations will be prevented.

which hook should i implement? by doing so when i select a product i will also be shown the page to choose the domain?

Share this post


Link to post
Share on other sites
24 minutes ago, luigidefra said:

which hook should i implement?

it would be ClientAreaPageCart - though ClientAreaPage would work too.

24 minutes ago, luigidefra said:

by doing so when i select a product i will also be shown the page to choose the domain?

yes.

this is a hook i've posted before (in many forms), but it allows you to specify which domain options are available for each product, e.g for some products, they can register a domain; for another product, they can register, transfer but not use own domain etc...

for your issue, i've simplified the code a little...

<?php

# Configure Domain Settings For Products
# Written by brian!

function domain_options_for_products_hook($vars) {
	
	$productinfo = $vars['productinfo'];
	if ($vars['templatefile']=="configureproductdomain") {
		$validproducts = array(1,2);
		if (in_array($productinfo['pid'],$validproducts)) {
			return array("registerdomainenabled" => "on", "domainoption" => "register"); 
		}
	}
}
add_hook("ClientAreaPageCart", 1, "domain_options_for_products_hook");

so what this says is that for the product IDs listed in the $validproducts array (that's 1 & 2), the domain options will include Domain Registration (even if disabled in the settings) and it will be the default choice... if transfer/owndomain options are enabled, then they'll be shown too (along with subdomain if that's applicable with the product) -

Share this post


Link to post
Share on other sites

Hi Brian, I am still writing to you about it.

I set the .it domain for € 10, then I set up shared hosting including a domain and set the free .it domain for it.

The cart shows me two items.
The first item is shared hosting including the free .it domain.
The second is the .it domain at a full price of € 10.

So I have a problem, if I delete shared hosting from the cart I can only buy the domain at full price and I shouldn't be allowed.

I should only have shared hosting including its free domain in my cart

Schermata 2020-11-12 alle 18.45.25.png

Schermata 2020-11-12 alle 18.44.08.png

Schermata 2020-11-12 alle 18.43.33.png

Schermata 2020-11-12 alle 18.42.54.png

Share this post


Link to post
Share on other sites
21 hours ago, luigidefra said:

So I have a problem, if I delete shared hosting from the cart I can only buy the domain at full price and I shouldn't be allowed.

it would be expected behaviour, when you remove a hosting product with domain (free or not), for the domain to remain in at the cart - but be charged at full price.

on your site, can users not register domains directly - they *must* be bought with products ? I suspect i've posted hooks before that prevent checkout if there are domains, but no products in the cart.

Share this post


Link to post
Share on other sites
On 11/13/2020 at 5:05 PM, brian! said:

on your site, can users not register domains directly - they *must* be bought with products ? I suspect i've posted hooks before that prevent checkout if there are domains, but no products in the cart.

At this moment on my site if I buy a hosting but I stop at the confirmation of the choice of the domain without buying the hosting I find only the domain in the cart.
Same behavior if I complete the purchase (hosting + domain) and then delete the hosting from the cart, I find only the domain in the cart.

It is true that he would buy the domain at full price but I just don't want to buy it

Share this post


Link to post
Share on other sites

well the reason why I asked if you can register domains directly is because if you don't, then it would make the prevention hook easier... e.g if cart contains a domain with no products at checkout, then prevent checkout.

hiding the option for the user to remove individual products would also prevent the issue lol.

Share this post


Link to post
Share on other sites
On 11/17/2020 at 6:01 PM, brian! said:

well the reason why I asked if you can register domains directly is because if you don't, then it would make the prevention hook easier.

 

On 9/21/2020 at 7:38 PM, luigidefra said:

Hi, In my project I can create a new domain only in bundle with shared hosting, then i need hide Register a new domain on header and left bar, how can i do?

so, how can i do?
you say to delete through hook all the domains with no products at checkout?

Please help me

Share this post


Link to post
Share on other sites

You can try using ShoppingCartValidateCheckout hook to check for domains within $_SESSION[‘cart’] and then returning error "blah product requires a domain registration, please pick a domain" and provide a link to the domain checker page.   If you want it to be specific to a product, then going through the items in the cart and check their pids against an array of pids that you want to be required to have a domain registration and return error as needed.

Share this post


Link to post
Share on other sites
On 11/19/2020 at 10:54 PM, steven99 said:

You can try using ShoppingCartValidateCheckout hook to check for domains within $_SESSION[‘cart’] and then returning error "blah product requires a domain registration, please pick a domain" and provide a link to the domain checker page.   If you want it to be specific to a product, then going through the items in the cart and check their pids against an array of pids that you want to be required to have a domain registration and return error as needed.

There is no hook to remove the item in the cart? So when a Domain or Hosting is deleted automatically remove the respective Domain or Hosting it belongs to

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