Juanzo Posted December 25, 2019 Share Posted December 25, 2019 We are enjoying Crisp.chat as a front desk for our WHMcs support tickets (great since it integrates chat and social networks). Their integration with WHMcs made things easier, but now I'm trying to improve their code to be able to show actvice services for identified clients. Any ideas on how could we insert active services? This is their hook now: <?php if(!defined("WHMCS")) { die("This file cannot be accessed directly"); } use WHMCS\Database\Capsule; function hook_crisp_footer_output($vars) { $website_id = Capsule::table('tbladdonmodules')->where('module', 'crisp')->where('setting', 'website_id')->value('value'); if(!$website_id) { return; } $output = "<script type='text/javascript'> window.CRISP_READY_TRIGGER = function() { "; if ($vars['clientsdetails']['email']) { $email = $vars['clientsdetails']['email']; $output .= "\$crisp.set('user:email', '$email');"; } // First and last name if ($vars['clientsdetails']['firstname']) { $name = $vars['clientsdetails']['firstname'] . " " . $vars['clientsdetails']['lastname']; $output .= "\$crisp.set('user:nickname', '$name');"; } // Information apart from First & Lastname that should be imported. Must exist in the clientsdetails-array. if(isset($vars['clientsdetails'])) { $merge_fields = [ 'id', 'companyname', 'address1', 'address2', 'city', 'state', 'postcode', 'country', 'phonenumber' ]; foreach($merge_fields as $merge_field) { if(isset($vars['clientsdetails'][$merge_field])) { $output .= "\$crisp.set('session:data', ['" . $merge_field . "', '" . $vars['clientsdetails'][$merge_field] . "']);"; } } } $output .= "};</script> <script type='text/javascript'>CRISP_WEBSITE_ID = '$website_id';(function(){d=document;s=d.createElement('script');s.src='https://client.crisp.chat/l.js';s.async=1;d.getElementsByTagName('head')[0].appendChild(s);})();</script> "; return $output; } add_hook('ClientAreaFooterOutput', 1, 'hook_crisp_footer_output'); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 27, 2019 Share Posted December 27, 2019 On 25/12/2019 at 18:53, Juanzo said: Any ideas on how could we insert active services? the client would need to be logged in, and then their services would have to be queried from the database - either by capsule (the hook already uses capsule), model or API if they'll logged in you'll have their user id from... $vars['clientsdetails']['userid'] then it's just a case of using that in a capsule query to tblhosting, and looping through the resulting array to output it.. though bear in mind that this would just get their services - not their domains or any product addons. 0 Quote Link to comment Share on other sites More sharing options...
Newton Posted March 8, 2023 Share Posted March 8, 2023 @Juanzo Did you ever figure out how to rewrite the hook to see active services? 0 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.