Jump to content

hookDisplayPayment addCSS and addJS


Recommended Posts

Hi,

 

It is on version1.6.1.16

 

I would need some extra css and js for my payment module's display payment part. It seems that adding this code at the hook is ignored. 

public function hookDisplayPayment($params)
{
    $this->context->controller->addCSS(_MODULE_DIR_.$this->name.'/views/css/simplepay.css');
    $this->context->controller->addJS(_MODULE_DIR_.$this->name.'/views/js/displaypayment.js');
    $this->context->smarty->assign(
        array(
         'this_path' => $this->_path,
         'validation_link' => $this->context->link->getModuleLink($this->name, 'validation', array(), true),
        )
    );
    return $this->display(__FILE__, 'displayPayment.tpl');
}

Any idea how to solve this?

 

The payment methods display after the user accepted terms of use. In this case the js file does not load. If the user refresh the page the payment methods automatically loads, and the js is also loads.

Link to comment
Share on other sites

move the addcss and addjs to the displayHeader hooks. 

$this->context->controller->addCSS(_MODULE_DIR_.$this->name.'/views/css/simplepay.css');
$this->context->controller->addJS(_MODULE_DIR_.$this->name.'/views/js/displaypayment.js');

when you check the TOS box, there is an ajax call made that returns only the content of the payment modules via that ajax call.  adding JS and CSS at this point will not work, you need to add them using the displayHeader hook, so that they are added to the page content prior to the TOS being checked.

  • Thanks 1
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...