I successfully integrated FB Messenger into my OpenCart 3.0.3.7 website using the instructions from here https://developers.facebook.com/docs/messenger-platform/reference/web-plugins/
JavaScript
x
25
25
1
<div id="fb-root"></div>
2
<script>
3
window.fbAsyncInit = function() {
4
FB.init({
5
xfbml : true,
6
version : 'v10.0'
7
});
8
};
9
10
(function(d, s, id) {
11
var js, fjs = d.getElementsByTagName(s)[0];
12
if (d.getElementById(id)) return;
13
js = d.createElement(s); js.id = id;
14
js.src = 'https://connect.facebook.net/el_GR/sdk/xfbml.customerchat.js';
15
fjs.parentNode.insertBefore(js, fjs);
16
}(document, 'script', 'facebook-jssdk'));
17
</script>
18
19
<!-- Your Chat Plugin code -->
20
<div class="fb-customerchat"
21
attribution="setup_tool"
22
page_id="00000000000000">
23
</div>
24
25
Under the default theme, it works perfectly and as expected, but when I use the zeexo theme for some reason (I suspect js or css conflict??) it shows a white circle that does not respond to anything. How to overcome this problem? What part of the code is responsible for this behavior?
Advertisement
Answer
There was a JS conflict with the theme’s Facebook widget.
All I had to do, was to replace the “bad” or old (??) JS code under the catalogviewthemezeexotemplatecommonheader.twig
JavaScript
1
8
1
<script>(function(d, s, id) {
2
var js, fjs = d.getElementsByTagName(s)[0];
3
if (d.getElementById(id)) return;
4
js = d.createElement(s); js.id = id;
5
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
6
fjs.parentNode.insertBefore(js, fjs);
7
}(document, 'script', 'facebook-jssdk'));</script>
8
with the newer, I got from the Facebook SDK
JavaScript
1
17
17
1
<script>
2
window.fbAsyncInit = function() {
3
FB.init({
4
xfbml : true,
5
version : 'v10.0'
6
});
7
};
8
9
(function(d, s, id) {
10
var js, fjs = d.getElementsByTagName(s)[0];
11
if (d.getElementById(id)) return;
12
js = d.createElement(s); js.id = id;
13
js.src = 'https://connect.facebook.net/el_GR/sdk/xfbml.customerchat.js';
14
fjs.parentNode.insertBefore(js, fjs);
15
}(document, 'script', 'facebook-jssdk'));
16
</script>
17
Now it works on both Facebook widget and FB messenger chat.