ouun / zammad-wp

Zammad WordPress integration
GNU General Public License v2.0
27 stars 5 forks source link

chat error || Chat: need chatId as option! #12

Closed sbu-WBT closed 3 years ago

sbu-WBT commented 3 years ago

I installed the plugin via wordpress.

I added those like described in Embed-Live-Chat to wp-content/themes/hestia/functions.php.

add_filter('zammad_wp:chat:defaults', function ($defaults) {
    return wp_parse_args(
        [
            'chatId' => 1,
            'background' => '#00B4FF',
        ],
        $defaults
    );
});

add_action('init', function () {
        if (function_exists('zammad_register_chat')) {
            zammad_register_chat($chatId, $args);
        }
    });

We have also the chat enabled: image

But we get the error chat error || Chat: need chatId as option! inside the browser console.

If we look at the chatOptions is also set there:

image

Wordpress Version 5.7.1

ouun commented 3 years ago

Hi @sbu-WBT, in your init action please replace $chatId with the id 1 and $args with your settings [ 'background' => '#00B4FF' ]

As you did not define the ID the function does not reach the filter you used to set the id. The filter is not required in your case anyway.

Ich hoffe das hilft. 😉

sbu-WBT commented 3 years ago

Ah danke, das hat geholfen. Der Fehler ist weg. (Auch wenn ich den Chat nirgends sehen kann^^)

ouun commented 3 years ago

@sbu-WBT hat es geklappt? In der Standardeinstellung wird der Chat nur angezeigt wenn auch ein Agent in Zammad online ist. Du kannst zusätzlich einen Fallback auf ein Formular setzen.

sbu-WBT commented 3 years ago

Vielen Dank für den Hinweis! Ja, das hat nun funktioniert. Wir sind noch ziemliche Zammad Newbies