# Compatibility with 3rd-Party Cookie-Plugins

In version 4.18.0 the possibility to support 3rd party cookie manager plugins was implemented.

The communication with the standard CookieConfigurator plugin was outsourced to a separate class, in order to be able to override it and individualize the function.

Accordingly, a separate JS code must be written for each 3rd party plugin to ensure compatibility.

Following is an example of such JS code, which establishes compatibility with the AcrisCookieConsentCS plugin (opens new window).

# Interface description

class CookieConsentInterface {
    // This method is called after the initialization of the CookieConfigurator
    _onInit(): void

    // This method is called as soon as the cookie selection has changed
    _onCookieConfigurationUpdated(updatedCookies: object): void

    // Events are registered here (e.g. for _onInit and _onCookieConfigurationUpdated).
    registerEvents(): void

    // This method is called to check if the CookieConfigurator is initialized.
    // If the method returns `false`, the method `waitForInitialization` is called.
    isInitialized(): bool

    // Opening the CookieConfigurator
    open(): void

    // The method is used to register a so-called callback,
    // so that our cookie class can react to the changed cookie selection.
    onUpdate(callback: function): void

    // As described above, this method is called when the CookieConfigurator is not yet initialized
    // Technically, the `resolve` callback is cached here and called in the `_onInit` method.
    waitForInitialization(): Promise

    // This method should return the plugin instance of the CookieConfigurator
    getPluginInstance(): object

    // This method returns `true` by default and is used to check,
    // whether the default cookie configurator is enabled or not.
    shouldCheckIfCookieConsentIsEnabled(): bool
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

# Example for overwriting the individual methods

The methods whose name starts with _ should not be overwritten, because their task is elementary for the correct functioning of the cookie logic.

This code should be implemented via the regular way (opens new window).

window.Neti.StoreLocator.getCookieConsentInterfaceClass = function() {
    const cookieConsentClass = window.Neti.StoreLocator.CookieConsentInterfaceClass;

    cookieConsentClass.prototype.open = function() {
        // Open your own cookie configurator
    }

    return cookieConsentClass;
};
1
2
3
4
5
6
7
8
9

If you have dealt with the original CookieConfigurator, you know that it does not fire an event by default. as soon as it has been initialized. We solved this problem by adding a after hook to the init method of the plugin.

This event is also elementary for our logic to know when this plugin was initialized.

window.Neti.StoreLocator.PluginOverride('CookieConfiguration', {
    init: {
        after() {
            document.$emitter.publish(PLUGIN_CONFIGURATION_INIT);
        }
    }
});
1
2
3
4
5
6
7

# Compatibility example with AcrisCookieConsentCS

As already announced above, here follows the example with the plugin AcrisCookieConsentCS, which ensures the basic compatibility with our plugin.

window.Neti.StoreLocator.getCookieConsentInterfaceClass = function() {
    const cookieConsentClass = window.Neti.StoreLocator.CookieConsentInterfaceClass;

    cookieConsentClass.prototype.open = function() {
        // Open the cookie manager
        this.getPluginInstance().openOffCanvas();

        // Ensure the cookie managers settings are opened
        if (!document.querySelector('.cookie-consent-setting-container').classList.contains('show')) {
            document.querySelector('#ccSettingButton').click();
        }
    }

    // Add an after-hook to the init method of the AcrisCookieConsent plugin to publish the required init event
    window.Neti.StoreLocator.PluginOverride('AcrisCookieConsent', {
        init: {
            after() {
                document.$emitter.publish('Neti_CookieConfiguration_Init');
            }
        }
    })

    return cookieConsentClass;
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

If you have any questions or problems with integration, feel free to contact us at any time (opens new window).