Access plugin configuration variables in Js file?

Hii so i access my plugin settings in a html.twig file trough this: 

 {% if shopware.config.StickyHeader.config.activateStickyHeader %} But now i wanna access the same thing in a .js file but i cant figure out how. If i use the same thing it will say that shopware isn't defined. Do i need to import something if so what? 

 

Thanks in advance!

Hi @SannNL‍ ,

have a look at this tutorial (Configuring your plugins) Shopware 6: Write your own storefront JavaScript plugin

This part is important:

Instead of examplePluginOption you can just pass your complete plugin configuration (shopware.config.StickyHeader.config). If you followed the whole tutorial, you should be able to access the settings inside your plugin with this.options.activateStickyHeader .

Happy coding.

1 „Gefällt mir“

Hey there.

I want to achieve the same: Access configuration values of my SW 6 extension inside a JS plugin.
But I want to plugin to be injected on all pages not just on a specific page, i.e. the plugin is not injected via a twig template.

Is there any way to access the configuration of the extension?