Add Javascript code nop 4.10

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hi all!

I am trying to insert a small block of javascript code in nopCommerce 4.10.

It is the Zopim chat code. I tried to insert it in the header of the '_Root.Head.cshtml' page but nothing is visible on the site. No error, but no chat is visible.

In version 3.40, entering it as I did worked fine.

This is the code:

<!--Start of Zopim Live Chat Script-->
    <script type="text/javascript">
        window.$zopim || (function (d, s) {
            var z = $zopim = function (c) { z._.push(c) }, $ = z.s =
                d.createElement(s), e = d.getElementsByTagName(s)[0]; z.set = function (o) {
                    z.set.
                        _.push(o)
                }; z._ = []; z.set._ = []; $.async = !0; $.setAttribute('charset', 'utf-8');
            $.src = '//v2.zopim.com/?xxxxxxxxxxxxxxxxxxxxxxxxxx'; z.t = +new Date; $.
                type = 'text/javascript'; e.parentNode.insertBefore($, e)
        })(document, 'script');
    </script>
    <!--End of Zopim Live Chat Script-->


How can I do?

Thanks for your help
5 years ago
Hello,

Try putting asp-location="footer" as an attribute of your script tag.

Hope that helps!

Regards,
Anton
5 years ago
Hi Anton,

what do you mean?Can you give me an example, with the code I posted?
5 years ago
Hello,

Your script tag should look something like:

<script type="text/javascript" asp-location="footer"> 
    //your js code here
</script>


Regards,
Anton
5 years ago
Hi Anton,

I tried as you advise me.

Unfortunately, the site crashes. This error appears: 'We're sorry, an internal error occurred.'

What can I do to enter it?
5 years ago
freedomx wrote:
This error appears: 'We're sorry, an internal error occurred.'

In case of this error, it would be good to have a look on log. So in admin panel go to system -> log. It should give you hint to find solution.

Regards,
Tom
5 years ago
Hi Tom,

I checked the log. It was written in capital letters 'asp-location = "Footer"'

However, the chat is not seen anyway. Tips?
5 years ago
Hi,

I Visited zopim site and it seems they change name to Zendezk. check here-https://www.zopim.com/



I generated new script and it working fine.

New script is like this

<!-- Start of  Zendesk Widget script -->
<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"> </script>
<!-- End of  Zendesk Widget script -->


I added it in head tag (under _Root.Head and also tried in _root.cshtml) and it working fine.



Just verify script from your dashboard and re-check it.
5 years ago
Perfect, it works.

Thank you very much Rajupaladiya!
5 years ago
Glad to hear it helped you.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.