Sabelo Simelane Posted March 30, 2017 Share Posted March 30, 2017 (edited) I would appreciate some help on using jQuery in my payment module that I'm adapting from 1.6 to 1.7. I need to somehow hook on to the hookPaymentOptions so that I can handle some events when the customer selects the payment method. I have tried using registerJavascript() but even though it's being called the javascript file is not loaded on the DOM. Basically, my question is, how do I use javascript/jQuery in my payment module specifically a tpl file or a separate js file. Any help will be appreciated. Thanks Edited March 30, 2017 by Sabelo Simelane (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted March 30, 2017 Share Posted March 30, 2017 you could use the displayHeader hook, and add the media files based on the page/controller Link to comment Share on other sites More sharing options...
Sabelo Simelane Posted March 31, 2017 Author Share Posted March 31, 2017 (edited) Hi Bellini13, really appreciate your response. I have tried using the displayHeader hook, it doesn't even fire. Here's a bit of my code: if (!parent::install() || !$this->registerHook('displayHeader') || !$this->registerHook('paymentOptions') || !$this->registerHook('paymentReturn')) return false; public function hookDisplayHeader($params) { error_log("in hookDisplayHeader..."); return $this->getScriptPlugins($params); } Am I mising something? :-( Edited March 31, 2017 by Sabelo Simelane (see edit history) Link to comment Share on other sites More sharing options...
Sabelo Simelane Posted March 31, 2017 Author Share Posted March 31, 2017 (edited) I've found the problem why those hooks were not firing. It seems I needed to uninstall the module first. If you just change something in the module and install "on top" of the previous version, it doesn't create the hooks, for some reason. After uninstalling and installing the module the hookHeader worked for me it loaded my js file and made jquery available. Edited March 31, 2017 by Sabelo Simelane (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted March 31, 2017 Share Posted March 31, 2017 the install function of your module is only ever called one time, when the module is actually installed. if you update the modules install function and then just copy the code to the modules folder, the install function is not going to be called again. thats important for module development, but you can easily work around that by using the module positions page in the back office. however what is more important, is that when you update your release modules, you need to consider that the merchants using your module have already installed it... So if the merchant uses v1.0 of your module and installs that. Then you release v1.1 of your module, and you updated the install/uninstall functions to include new hooks Now merchant downloads v1.1 of your module and installs/adds/uploads it to their shop, the install function is NOT called again. Therefore you need to include upgrade scripts in your module to account for that scenario... Link to comment Share on other sites More sharing options...
Sabelo Simelane Posted March 31, 2017 Author Share Posted March 31, 2017 Thanks Bellini13 for the revelation there, I was not aware of that. So, what would typically go into the upgrade script? Could I instead, call the uninstall then call the install function in the upgrade script? Also, I have noted that with PS 1.7, when you uninstall a module, the module files are not deleted. I read in the documentation that the files are supposed to be deleted. Is that the correct behaviour? Regards, Sabelo Link to comment Share on other sites More sharing options...
bellini13 Posted April 1, 2017 Share Posted April 1, 2017 uninstalling a module never deletes the module, it never has done that. you need to delete the module separately after uninstalling it. as for as upgrade script goes, look at the ps_checkpayment/upgrade folder for examples. Link to comment Share on other sites More sharing options...
Sabelo Simelane Posted April 2, 2017 Author Share Posted April 2, 2017 Thanks Bellini13, I have managed to implement and upgrade script and it's working like a charm. Thanks again. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now