Jump to content

Can not add external javascript with data-complete attributes in controller and smarty template


Jahangir

Recommended Posts

I am developing a custom payment module in PrestaShop 1.6 my front controller path is: mymodule/controllers/front/payment.php

payment.php contains:

$this->context->smarty->assign(array( 
'dataCompleteURL' =>  Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__.'index.php?fc=module&module=mymodule&controller=callback&cart='.$cartID));
$this->setTemplate('payment.tpl');

my template file path is: mymodule/views/templates/front/payment.tpl

payment.tpl contains:

<script src="http://easternbank.test.gateway.com/checkout.js" data-complete="{$dataCompleteURL}" type="text/javascript"> </script>

The problem is In my localhost it is working fine. I get data-complete URL in script tag. But when I install the module in my test server I do not get the data-complete URL.

 

I have found that the problem is "https" in "src" of script tag. I can not understand why data-complete vanishes if the src URL begins with https. without https it is okay

when I view the source from browser for the following code with https in src:

<script src="http://easternbank.test.gateway.com/checkout.js" data-complete="{$dataCompleteURL}" type="text/javascript"> </script> 

data-complete attribute vanishes. But when I view source for the script with src without "https" I get the data-complete attribute.

I could not find the reason.

 

I can add javascript in controller payment.php using :

$this->context->controller->addJS(($this->_path).'js/checkout.js'); 

But do not know how to pass data attributes in addJS function.

 

Any help or suggestion will be appreciated. Thanks in advance.

Edited by Jahangir (see edit history)
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...