Have you checked this?
https://forum.livehelperchat.com/viewtopic.php?id=1739
How do I execute this script?
Re: How do I execute this script?
Omar_one wrote: ↑Tue Nov 29, 2022 6:43 pm @Rich-Os
you can add pages to hookand called ScriptCode: Select all
var $good_pages = ['index.php', 'xxxx.php', 'xxxx.php']; // what pages do you want to load the livehelperchat script
Code: Select all
$livehelperchatScript = <<<eod <script>(HERE THE SCRIPT) </script> eod;
Very nice of you @Omar_one
But the script is supposed to appear on all pages (by right) but this selective addition idea might come handy later, so, thank you.
I'm not sure if this script (to add pages to hook) is supposed to be a separate file for hooks or included in the first script like so below:
(note I didn't use the <<<eod as it was making browser throw HTTP ERROR 500)
Re: How do I execute this script?
Code: Select all
class hook_shop_siteWide_livehelperchat {
var $version = '3.4.1';
var $sitestart = null;
var $good_pages = ['index.php', 'conditions.php', 'shipping.php']; // what pages do you want to load the livehelperchat script
function listen_injectSiteStart() {
$this->sitestart .= '<!-- livehelperchat hooked -->' . PHP_EOL;
$livehelperchatScript .= '<script>var LHC_API = LHC_API||{};
LHC_API.args = {mode:"widget",lhc_base_url:"//mysite.com/livehelperchat/lhc_web/index.php/",wheight:450,wwidth:350,pheight:520,pwidth:500,leaveamessage:true,check_messages:false};
(function() {
var po = document.createElement("script"); po.type = "text/javascript"; po.setAttribute("crossorigin","anonymous"); po.async = true;
var date = new Date();po.src = "//mysite.com/livehelperchat/lhc_web/design/defaulttheme/js/widgetv2/index.js?"+(""+date.getFullYear() + date.getMonth() + date.getDate());
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);
})();
</script>' . PHP_EOL;
if (in_array(basename($_SERVER['PHP_SELF']), $this->good_pages)) {
$this->sitestart .= $livehelperchatScript . PHP_EOL;
return $this->sitestart;
}
}
}
Re: How do I execute this script?
Even apart from not using the <<<eod syntax, I'm not sure I placed the above codes right. Could you see what I did wrong? Thanks so much again.
Re: How do I execute this script?
Yes, I have. Thank you.mecinta wrote: ↑Wed Nov 30, 2022 6:25 am Have you checked this?
https://forum.livehelperchat.com/viewtopic.php?id=1739
I have no issue with SSL as the generated embedded codes seem to work fine. My problem is that widget will not appear on pages unless I actually type the page address fully in browser. Looks like a typical cache problem but everything I did to clear browsers cache/history, etc doesn't work.
-
- VIP Member
- Posts: 481
- Joined: Fri Oct 25, 2019 5:06 pm
- Has thanked: 48 times
- Been thanked: 27 times
Re: How do I execute this script?
@Rich-Os the first hook I shared working well on every page (locally)