I am attempting to replace an existing JavaScript plugin in Shopware 6. However, the code within the plugin file does not seem to execute.
Here is my main.js:
import MyCookiePermissionPlugin from './plugin/my-cookie-permission/my-cookie-permission.plugin';
const PluginManager = window.PluginManager;
PluginManager.override('CookiePermission', MyCookiePermissionPlugin, '[data-cookie-permission]');
console.log('test1');
And this is my my-cookie-permission.plugin.js:
import CookiePermissionPlugin from 'src/plugin/cookie/cookie-permission.plugin';
export default class MyCookiePermissionPlugin extends CookiePermissionPlugin {
init() {
console.log('test2');
CookieStorage.setItem(this.options.cookieName, '');
super.init();
}
_hideCookieBar() {
if (confirm('Do you want to hide the cookie bar?')) {
super._hideCookieBar();
}
}
}
When I build the storefront, delete all cookies, and refresh the page, only "test1" is logged in the console, while "test2" is missing, even though it should be executed when the Plugin Permission Bar of Shopware is displayed. What could be the issue here?