souzadavi Posted October 20, 2020 Share Posted October 20, 2020 The addon tawkto is creating a error o WHMCS 8.0. Below is the code. If you know how to fix please let me know. Thanks <?php use Illuminate\Database\Capsule\Manager as Capsule; function tawkto_check($vars) { $uid = $_SESSION['uid']; //get the code $widgetScript = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-script')->pluck('value'); if (is_array($widgetScript)) { $widgetScript = current($widgetScript); } if ($widgetScript) { // $widgetScript = addslashes($widgetScript); // this breaks the widget script when displayed on client side // $widgetScript = htmlentities($widgetScript); // this displays the script as html text and prevents proper rendering of the script $widgetScript = trim($widgetScript); } else { return; } // get the API key, if set $apikey = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-key')->pluck('value'); if (is_array($apikey)) { $apikey = current($apikey); } if ($apikey) { $apikey = trim($apikey); } //no tawk-y (for now) $isenabled = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-enable')->WHERE('value' , 'on')->count(); if (empty($isenabled)) { return; } //clients only $clientsonly = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-clientsonly')->WHERE('value' , 'on')->count(); if (!empty($clientsonly)) { if (empty($uid)) { return; } } //maybe we just wanna chat with guests? $guestonly = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-unregonly')->WHERE('value' , 'on')->count(); if (!empty($guestonly)) { if (!empty($uid)) { return; } } // no name is show by default $tawkname = ""; if (isset($uid)) { //to name, or not to name, that is the question $showname = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-name')->WHERE('value' , 'on')->count(); if ($showname) { //now we get what we get! foreach (Capsule::table('tblclients') ->WHERE('id', $uid)->get() as $tawkclients) { $fname = html_entity_decode($tawkclients->firstname, ENT_QUOTES); $tlname = html_entity_decode($tawkclients->lastname, ENT_QUOTES); $fname = addslashes($fname); $lname = addslashes($tlname); $company = $tawkclients->companyname; $emailaddress = $tawkclients->email; } // show in secure mode if api key is set. else, show basic name/email info if (($fname || $lname) && $emailaddress) { if ($apikey && strlen($apikey) > 10) { $hash = hash_hmac("sha256", $emailaddress, $apikey); $tawkname = "Tawk_API.visitor = { name : '{$fname} {$lname}', email : '{$emailaddress}', hash : '{$hash}' };"; } else { $tawkname = "Tawk_API.visitor = { name : '{$fname} {$lname}', email : '{$emailaddress}' };"; } } } } //get the key $tawkreturn = "$widgetScript"; $tawkreturn = str_ireplace('</script>', $tawkname.'</script>', $tawkreturn); return($tawkreturn); } function tawkto_check_invoice($vars) { $uid = $_SESSION['uid']; //get the code $widgetScript = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-script')->pluck('value'); if (is_array($widgetScript)) { $widgetScript = current($widgetScript); } if ($widgetScript) { // $widgetScript = addslashes($widgetScript); // this breaks the widget script when displayed on client side // $widgetScript = htmlentities($widgetScript); // this displays the script as html text and prevents proper rendering of the script $widgetScript = trim($widgetScript); } else { return; } // get the API key, if set $apikey = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-key')->pluck('value'); if (is_array($apikey)) { $apikey = current($apikey); } if ($apikey) { $apikey = trim($apikey); } //no tawk-y (for now) $isenabled = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-enable')->WHERE('value' , 'on')->count(); if (empty($isenabled)) { return; } //clients only $clientsonly = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-clientsonly')->WHERE('value' , 'on')->count(); if (!empty($clientsonly)) { if (empty($uid)) { return; } } //maybe we just wanna chat with guests? $guestonly = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-unregonly')->WHERE('value' , 'on')->count(); if (!empty($guestonly)) { if (!empty($uid)) { return; } } // no name is show by default $tawkname = ""; if (isset($uid)) { //to name, or not to name, that is the question $showname = Capsule::table('tbladdonmodules')->select('value')-> WHERE('module', '=' , 'tawkto')->WHERE('setting' , '=', 'tawkto-name')->WHERE('value' , 'on')->count(); if ($showname) { //now we get what we get! foreach (Capsule::table('tblclients') ->WHERE('id', $uid)->get() as $tawkclients) { $fname = html_entity_decode($tawkclients->firstname, ENT_QUOTES); $tlname = html_entity_decode($tawkclients->lastname, ENT_QUOTES); $fname = addslashes($fname); $lname = addslashes($tlname); $company = $tawkclients->companyname; $emailaddress = $tawkclients->email; } // show in secure mode if api key is set. else, show basic name/email info if (($fname || $lname) && $emailaddress) { if ($apikey && strlen($apikey) > 10) { $hash = hash_hmac("sha256", $emailaddress, $apikey); $tawkname = "Tawk_API.visitor = { name : '{$fname} {$lname}', email : '{$emailaddress}', hash : '{$hash}' };"; } else { $tawkname = "Tawk_API.visitor = { name : '{$fname} {$lname}', email : '{$emailaddress}' };"; } } } } //get the key $tawkreturn = "$widgetScript"; $tawkreturn = str_ireplace('</script>', $tawkname.'</script>', $tawkreturn); echo $tawkreturn; } // JUST COMMENT LINES BELOW TO FIX THE ERROR //add_hook("ClientAreaFooterOutput",1,"tawkto_check"); //add_hook("ClientAreaPageViewInvoice",1,"tawkto_check_invoice"); 0 Quote Link to comment Share on other sites More sharing options...
SubZeroFX Posted October 21, 2020 Share Posted October 21, 2020 Any error message is showing for you? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 21, 2020 Share Posted October 21, 2020 16 hours ago, souzadavi said: The addon tawkto is creating a error o WHMCS 8.0. the tawkto_check function is already used by the tawkto addon (if enabled in the addon) - so this hook causes an error because the function is getting redeclared by it. if it were me, i'd just use the hook that comes with the addon - and because the invoice page doesn't have a footer and therefore the chat doesn't appear on that page, i'd just copy & paste the tawk script code and paste it before the closing </body> tag in the template (if you need to have the chat on the view invoice page). 0 Quote Link to comment Share on other sites More sharing options...
souzadavi Posted October 21, 2020 Author Share Posted October 21, 2020 Hello guys, @SubZeroFX there is no error. But this is the second Hook I need to disable because not working in this new version.... @brian! this is the tawkto addon, this solution would works, but i would like to use the addon. Thanks for all. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 21, 2020 Share Posted October 21, 2020 1 minute ago, souzadavi said: @brian! this is the tawkto addon, this solution would works, but i would like to use the addon. the hook you posted is a combination of the default hook (to show the chat on every page), and another hook to show it on the viewinvoice page - what i'm saying is that you don't need the above hook... the tawkto addon can add the script to the footer using a hook very similar to above... the only thing you need to worry about is the invoice page (if that's important to you). 0 Quote Link to comment Share on other sites More sharing options...
Maison Posted October 29, 2020 Share Posted October 29, 2020 Have version update for whmcs 8 1.30 Compatible with WHMCS v8.0 Link download https://downloads.tawk.to/plugins/whmcs/whmcs_tawk_to_1_3.zip https://marketplace.whmcs.com/product/3134-tawkto-live-chat 2 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.