Jump to content

Using Jquery on Prestashop 1.7 Payment Module's tpl file


Recommended Posts

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 by Sabelo Simelane (see edit history)
Link to comment
Share on other sites

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 by Sabelo Simelane (see edit history)
Link to comment
Share on other sites

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 by Sabelo Simelane (see edit history)
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...