Jump to content

Hook to pass the registrar info to the clientareaproductdetails


plusplushosting

Recommended Posts

Hi there,

I have modified this Brian's hook i had....(phone for Brian 🙂 )  but is not passing the array for any reason, i guess im missing something. I wish to pass the registrar information to the clientareaproductdetails tpl

Any help will be great. Thanx in advance!

 

<?php

# Written by brian!

use WHMCS\Database\Capsule;

function cdomain_renewals_registrar_name_inproddetails_hook($vars) {

        if ($vars['templatefile'] == 'clientareaproductdetails') {
                $client = Menu::context('client');
                $domains = $vars['domains'];
                foreach($domains as $key => $domain) {
                        $registrar = Capsule::table('tbldomains')->where('userid',$client->id)->where('domain',$domain['domain'])->value('registrar');
                        if ($registrar) {
                                $domains[$key]['registrar'] = $registrar;
                        }
                }
        }
        return array ("domains2" => $domains);
}
add_hook("ClientAreaPage", 1, "cdomain_renewals_registrar_name_inproddetails_hook");

 

Link to comment
Share on other sites

13 hours ago, plusplushosting said:

i guess im missing something

the productdetails page wouldn't have a $domains array - only the value of a single domain (if one is associated with that service).

to get the registrar value on that page, you could do...

<?php

# Product Details Domain Registrar Hook
# Written by brian!

use WHMCS\Database\Capsule;

function cdomain_renewals_registrar_name_inproddetails_hook($vars)
{
	$client = Menu::context('client');
	$domainID = intval($vars['domainId']);
	if (!empty($domainID)) {
		$registrar = Capsule::table('tbldomains')->where('userid',$client->id)->where('id',$domainID)->value('registrar');
		return array("registrar" => $registrar);
	}
}
add_hook("ClientAreaPageProductDetails", 1, "cdomain_renewals_registrar_name_inproddetails_hook");

and that will give you a $registrar value that you can either use further in the hook, and/or return it to the template so it can be accessed by it.

and to answer your next question - yes it would be possible to output this value on the page - either using this hook, using a jQuery hook or directly in the template... which is best depends on where you want to add the output.

Link to comment
Share on other sites

17 hours ago, plusplushosting said:

But is half working

oh you wanted it 100% working? 😲

17 hours ago, plusplushosting said:

As im using the /modules/servers/cpanel/templates/overview.tpl  to modify the product details page, is not passing the variable there, even it is in the productdetails template i guess the include of overvirew.tpl is the problem.

then change the hook from ClientAreaPageProductDetails to ClientAreaProductDetailsPreModuleTemplate and that should work.

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.

  • 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