2
2
3
3
/***************************************************************************
4
4
// * *
5
- // * Chatwoot WHMCS Addon (v1.1 ). *
5
+ // * Chatwoot WHMCS Addon (v1.2 ). *
6
6
// * This addon modules enables you integrate Chatwoot with your WHMCS *
7
7
// and leverage its powerful features. *
8
8
// * Tested on WHMCS Version: 7.9.2 (7.9.2-release.1). *
@@ -79,35 +79,41 @@ function hook_chatwoot_footer_output($vars) {
79
79
if (!is_null ($ client )){
80
80
$ chatwoot_output = "$ chatwoot_jscode
81
81
<script>
82
- window.onload = (event) => {
82
+ window.addEventListener('chatwoot:ready', function () {
83
83
window. \$chatwoot.setUser(' $ clientid', {
84
84
email: ' $ clientemail',
85
85
name: ' $ clientname',
86
86
avatar_url: ' $ gravatarurl',
87
- })
87
+ });
88
+
88
89
window. \$chatwoot.setLabel(' $ chatwoot_label')
89
- }
90
- window.chatwootSettings = {
91
- position: ' $ chatwoot_position',
92
- locale: ' $ chatwoot_lang',
93
- }
90
+
91
+ window.chatwootSettings = {
92
+ position: ' $ chatwoot_position',
93
+ locale: ' $ chatwoot_lang',
94
+ }
95
+ });
94
96
</script>
95
97
" ;
96
- } else {
98
+ }
99
+ else {
97
100
$ chatwoot_output = "$ chatwoot_jscode
98
101
<script>
99
- window.onload = (event) => {
102
+ window.addEventListener('chatwoot:ready', function () {
100
103
window. \$chatwoot.setLabel(' $ chatwoot_label')
101
- }
102
- window.chatwootSettings = {
103
- position: ' $ chatwoot_position',
104
- locale: ' $ chatwoot_lang',
105
- }
104
+
105
+ window.chatwootSettings = {
106
+ position: ' $ chatwoot_position',
107
+ locale: ' $ chatwoot_lang',
108
+ };
109
+ });
106
110
</script>
107
111
" ;
108
- }
109
-
110
- echo $ chatwoot_output ;
112
+ }
113
+
114
+
115
+ // Now print JS code
116
+ echo $ chatwoot_output ;
111
117
}
112
118
113
119
@@ -118,10 +124,8 @@ function hook_chatwoot_logout_footer_output($vars) {
118
124
});
119
125
</script>
120
126
" ;
121
-
122
127
echo $ chatwoot_logoutJS ;
123
128
}
124
129
125
130
add_hook ('ClientAreaFooterOutput ' , 1 , 'hook_chatwoot_footer_output ' );
126
-
127
131
add_hook ('ClientLogout ' , 1 , 'hook_chatwoot_logout_footer_output ' );
0 commit comments