How do I execute this script?

Ask the community for help and support.
mecinta
Posts: 5
Joined: Sun Nov 07, 2021 1:28 pm
Has thanked: 6 times
Been thanked: 4 times

Re: How do I execute this script?

Post by mecinta »

I am from a land of Melayu, Cina and Tamil
Rich-Os
Posts: 10
Joined: Thu Sep 30, 2021 2:03 pm
Has thanked: 4 times

Re: How do I execute this script?

Post by Rich-Os »

Omar_one wrote: Tue Nov 29, 2022 6:43 pm @Rich-Os
you can add pages to hook

Code: Select all

 var $good_pages = ['index.php', 'xxxx.php', 'xxxx.php']; // what pages do you want to load the livehelperchat script 
and called 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)
Rich-Os
Posts: 10
Joined: Thu Sep 30, 2021 2:03 pm
Has thanked: 4 times

Re: How do I execute this script?

Post by Rich-Os »

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;
  }

 }
}
Rich-Os
Posts: 10
Joined: Thu Sep 30, 2021 2:03 pm
Has thanked: 4 times

Re: How do I execute this script?

Post by Rich-Os »

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.
Rich-Os
Posts: 10
Joined: Thu Sep 30, 2021 2:03 pm
Has thanked: 4 times

Re: How do I execute this script?

Post by Rich-Os »

mecinta wrote: Wed Nov 30, 2022 6:25 am Have you checked this?
https://forum.livehelperchat.com/viewtopic.php?id=1739
Yes, I have. Thank you.
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.
Omar_one
VIP Member
VIP Member
Posts: 406
Joined: Fri Oct 25, 2019 5:06 pm
Has thanked: 39 times
Been thanked: 19 times

Re: How do I execute this script?

Post by Omar_one »

@Rich-Os the first hook I shared working well on every page (locally)
Rich-Os
Posts: 10
Joined: Thu Sep 30, 2021 2:03 pm
Has thanked: 4 times

Re: How do I execute this script?

Post by Rich-Os »

Omar_one wrote: Thu Dec 01, 2022 6:51 pm @Rich-Os the first hook I shared working well on every page (locally)
Yeah, but unfortunately, this can't be reproduced on the web with my site.
Post Reply