Jump to content

Hide certain domain options at checkout


sven30

Recommended Posts

I have one product that I only want customers to register a new domain with their hosting. Meaning, no option for "Transfer your domain from another registrar" and no option for "I will use my existing domain and update my nameservers". Just registration option only. I just want to hide those other 2 options for this one hosting product only.  pid=174 How would I configure this?

Attached is what is currently there and what I'm wanting to hide.

I can't find any info on hooks for this domain options area. and I really can't seem to find it in templates either. It must be in the core. Is there a way I could hide it via css or some other way using hooks still? I know all the options in admin are more "all or nothing"...or globally set for all products.


Any help would be much appreciated.

pic487.jpg

domainoptions-hidden.jpg

Link to comment
Share on other sites

we could use ActionHooks for this, create new PHP file inside /includes/hooks/ directory, and put the following code inside it:

<?php

/**
 * Disable the use of domain transfer, own domains for specific products, only domain register will be available
 *
 * @author	SENTQ
 */

add_hook("ClientAreaPage", 1, function($vars){
    
	// Specify Products IDs, where only domain registration will be available for, separate by comma ","
    $productIds = array(174, 175, 178);
    
    if ($vars['filename'] == "cart" && $vars['action'] == "add" && in_array($vars['productinfo']['pid'], $productIds)){
    
        return array("transferdomainenabled" => false, "owndomainenabled" => false);
    
    }
    
});

 

Link to comment
Share on other sites

4 minutes ago, sentq said:

we could use ActionHooks for this, create new PHP file inside /includes/hooks/ directory, and put the following code inside it:


<?php

/**
 * Disable the use of domain transfer, own domains for specific products, only domain register will be available
 *
 * @author	SENTQ
 */

add_hook("ClientAreaPage", 1, function($vars){
    
	// Specify Products IDs, where only domain registration will be available for, separate by comma ","
    $productIds = array(174, 175, 178);
    
    if ($vars['filename'] == "cart" && $vars['action'] == "add" && in_array($vars['productinfo']['pid'], $productIds)){
    
        return array("transferdomainenabled" => false, "owndomainenabled" => false);
    
    }
    
});

 

This worked like perfectly!  Thank you so much!!

Link to comment
Share on other sites

13 minutes ago, brian! said:

i'd be tempted to use ClientAreaPageCart and then you won't have to check that filename eq "cart"... but i'm just being picky. :P

I might test that.

Where you do guys find all these variables?  Like transferdomainenabled and owndomainenabled?  Is there a whmcs docs page with all of them?  I know there's a hook index page, but curious if there was one for all these obscure ones. 

Link to comment
Share on other sites

1 hour ago, brian! said:

i'd be tempted to use ClientAreaPageCart and then you won't have to check that filename eq "cart"... but i'm just being picky. :P

I don't know if client's version of WHMCS support this ActionHook point, WHMCS never mention in what version it was introduced (except in release notes), this way it's compatible with any version, right 9_9

1 hour ago, sven30 said:

I might test that.

Where you do guys find all these variables?  Like transferdomainenabled and owndomainenabled?  Is there a whmcs docs page with all of them?  I know there's a hook index page, but curious if there was one for all these obscure ones. 

inside any template file use this smarty tag {debug} for a popup window with all available variables

Link to comment
Share on other sites

16 minutes ago, sentq said:

I don't know if client's version of WHMCS support this ActionHook point, WHMCS never mention in what version it was introduced (except in release notes), this way it's compatible with any version, right 9_9

inside any template file use this smarty tag {debug} for a popup window with all available variables

I'm running v7.4.1 and about to upgrade to v7.4.2

Link to comment
Share on other sites

Thanks guys for your help.  One thing I'be been wanting to do is trim down my code.  Is it possible for someone to help me do this?  Here's my complete code for this product custom cart layout (some of which we worked on above).  Is there a way I can consolidate some of these hooks and if/else statements?  I'm not a real programmer or a sufficient one anyway and there's a lot of redundancy in my code.   Basically what my full hook file does is removes a lot of secondary and primary sidebar and navbar items, and the domain options, and mobile view dropdowns.  Let me know. 

<?php

/*
Removes shopping cart left sidebar for student package only.
*/

use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $SecondarySidebar)
{

//Find out about product and remove items from sidebar
$produtsSize=sizeOf($_SESSION['cart']['products']);
$nosidebar=false;

for($i = 0; $i < $produtsSize;$i++) {
if ($_SESSION['cart']['products'][$i]['pid'] == 174) {
$nosidebar=true;
    }
  }

  if($nosidebar || $_GET['pid']=="174")
  {
  if(!is_null($SecondarySidebar->getChild('Categories'))){
  $SecondarySidebar->removeChild('Categories')
                   ->removeChild('Actions')
                   ->removeChild('Product Categories')
                   ->removeChild('Choose Currency');
      }
   }
});

/*
Removes items from primary header nav if student package only.
*/

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{

//Find out about product and remove items from primarynavbar
$produtsSize=sizeOf($_SESSION['cart']['products']);
$nosidebar=false;

for($i = 0; $i < $produtsSize;$i++) {
if ($_SESSION['cart']['products'][$i]['pid'] == 174) {
$nosidebar=true;
    }
  }

  if($nosidebar || $_GET['pid']=="174") {

   $client = Menu::context('client');
   if (is_null($client)) {
echo $lastpage;
    $primaryNavbar->addChild('Home')
        ->setUri('https://www.allwebnow.com/students')
        ->setOrder(0);

   if (!is_null($primaryNavbar->getChild('Store'))) {
       $primaryNavbar->removeChild('Store')
                 ->removeChild('Affiliates')
                 ->removeChild('Knowledgebase')
                 ->removeChild('Network Status')
                 ->removeChild('Announcements');
       }
   }
} 
});

/*
Removes Account drop down at top right for just student package only.
*/

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{

//Find out about product and remove items from secondarynavbar
$produtsSize=sizeOf($_SESSION['cart']['products']);
$nosidebar=false;

for($i = 0; $i < $produtsSize;$i++) {
if ($_SESSION['cart']['products'][$i]['pid'] == 174) {
$nosidebar=true;
    }
  }

  if($nosidebar || $_GET['pid']=="174") {

   $client = Menu::context('client');
   if (is_null($client)) {

   if (!is_null($secondaryNavbar->getChild('Account'))) {
       $secondaryNavbar->removeChild('Account');
       }
   }
} 
});
add_hook("ClientAreaPage", 1, function($vars){

	// Specify Products IDs, where only domain registration will be available for, separate by comma ","
    $productIds = array(174);
    
    if ($vars['filename'] == "cart" && $vars['action'] == "add" && in_array($vars['productinfo']['pid'], $productIds)){
    
        return array("transferdomainenabled" => false, "owndomainenabled" => false);
     }
});

//Find out about product and remove mobile product dropdown and currenty if in mobile view
$produtsSize=sizeOf($_SESSION['cart']['products']);
$nosidebar=false;

for($i = 0; $i < $produtsSize;$i++) {
if ($_SESSION['cart']['products'][$i]['pid'] == 174) {
$nosidebar=true;
    }
  }
  if($nosidebar || $_GET['pid']=="174") {

// removes mobile currency dropdown
function RemoveCurrency($vars)
{
$output .=  "<script type=\"text/javascript\">
			jQuery( \"select[name='currency']\" ).remove();
			</script>";

return $output;
}

add_hook("ClientAreaFooterOutput",1,"RemoveCurrency");

//removes mobile product category dropdown
function RemoveProduct($vars)
{
       $output .=  "<script type=\"text/javascript\">
                              jQuery('optgroup[label=\"Product Categories\"]').remove();
                               </script>";
       return $output;
}

add_hook("ClientAreaFooterOutput",1,"RemoveProduct");
}
?>

 

Link to comment
Share on other sites

19 hours ago, sentq said:

I don't know if client's version of WHMCS support this ActionHook point, WHMCS never mention in what version it was introduced (except in release notes), this way it's compatible with any version, right 9_9

fair enough... if only WHMCS had detailed documentation about this sort of thing. :roll:

Link to comment
Share on other sites

UPDATE:  So I did a whmcs upgrade to latest version and now this hook that you guys helped with doesn't seem to hide the other domain name options. Did anything change that anyone knows about in the latest release or is this hook no longer valid?  If so, let me know if I need to change anything to the below code.  

 

add_hook("ClientAreaPage", 1, function($vars){

	// Specify Products IDs, where only domain registration will be available for, separate by comma ","
    $productIds = array(174);

    if ($vars['filename'] == "cart" && $vars['action'] == "add" && in_array($vars['productinfo']['pid'], $productIds)){

        return array("transferdomainenabled" => false, "owndomainenabled" => false);
     }
});

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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