How to inject JavaScript into every page from ActionFilter?

11 meses atrás
Hi, I am wondering how to inject JavaScript into every page from ActionFilter from my custom plugin. I don't want to edit the views themselves.
In ActionFilter I have some code that checks if the geolocation is set in the Session and some other things as well. If they are not set, I want to inject the javascript to capture geolocation and wrap it into ajax, to send it back to a controller and save it. Then I want to refresh the page with the response from controller, in the js.
11 meses atrás
Although I suppose it could be done with an Action filter, you may want to look at an example of how it can be done using HtmlHelper AddScriptParts (in HandleEventAsync(PageRenderingEvent  )

\nopC460\Plugins\Nop.Plugin.Payments.CyberSource\Services\EventConsumer.cs
11 meses atrás
Thank you, I will look at it... Do I need a IWidget or can I do it with just plugin?
Also, do you know how I could add a custom section jn the product and category edit pages. So I would add an additional card and an input. Also how could I capture when the page is saved?, So I could save it to my table?
And also, one more question, do you maybe know how I coupd maybe like force app restart in my configure page. When I save I need the user to restart the store, so the changes fully apply.
11 meses atrás
You don't need to create a Widget plugin.  Just inherit from BasePlugin, IMiscPlugin.

Please post separate topics for each of your other issues.