What's New
Viewing 10 posts - 1 through 10 (of 10 total)
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic.
Tagged: popup newsletter, stnewsletter.js
Hi
I need to add some custom functionality to the Popup Newsletter JS file but i have no luck. This is what i have done:
1) created override for “/modules/stnewsletter/views/js/stnewsletter.js” in folder “/themes/MYTHEME/modules/stnewsletter/views/js/stnewsletter.js”
2) i added the changes to this file, but no effect
3) i searched and it seems this JS is not even included??? not even defined in main module file?
4) theme.js however has some scripts related to this module which i think overrides this JS file and takes care of the whole newsletter email submit
So my questions:
1) do i remove the stnewsletter JS code from theme.js, since latter is minified (where is original unminified version?)?
2) how do i use stnewsletter.js as in stnewsletter.php module there is no hook defined to call this JS file?
Suggestion: if i can find unminified theme.js than i think i can remove this code from it, than minify it again, than i can add my changes to custom.js
It’s not good that you hard-coded this part in theme.js!
I tried to describe my issue as deeply and as detailed as possible so please offer me a proper solution.
Thanks
Hi
You did not gave me a solution again 🙂
So, i don’t need to do anything with the popup, it’s the normal newsletter field added to homepage with VC. If success, i want to:
– clear the newsletter value from email address
– delete success message with a settimeout
If problems:
– delete error message with the settimeout
I added all these in the stnewsletter.js, but nothing happens. It means this file is for popup type NS only. I need it customized for the normal.
So as a side action i need to:
– un-minify theme.js
– remove or edit the NS related JS in theme.js
– minify theme.js
OR —
– remove NS related JS from theme.js
– include stnewsletter.js to be loaded with Prestashop and add my code to it
Thanks
Hi,
Two steps to do it:
1. Modify the \themes\transformer\assets\js\theme.js file, remove the js code, see the code.txt file.
See attached screenshot.
2. Modify the /modules/stnewsletter/stnewsletter.php file, add the following code:
$this->context->controller->registerJavascript('modules-stnewsletter', 'modules/'.$this->name.'/views/js/stnewsletter.js');
See attached screenshot.
3. Copy the \themes\transformer\_dev\js\stnewsletter.js file to /modules/stnewsletter/views/js/ folder and remove the following code:
import $ from 'jquery';
import Cookies from 'js-cookie';
See attached screenshot.
Then you can customize the stnewsletter.js file. But you need to re-do the changes after you update the theme.
Best regards.
Hi,
1. I attached the _dev/stnewsletter.js file.
2. The stnewsletter.js file in the module folder is different from the one I attached.
3. Try removing the code as my screenshot.
Best regards.
You must be logged in to reply to this topic.