cinopower Posted February 5, 2014 Share Posted February 5, 2014 Hi,I have a problem in my shop.Whatever I install in a hook (payment hook in this case) it doesn't show in the page...The old modules that are installed in this hook, are showing without problems...I made a test, just creating a module that register in the payment hook, thats the code: <?php if (!defined('_PS_VERSION_')) exit; class Base extends Module{ public function __construct(){ $this->name = 'base'; $this->tab = 'others'; $this->version = '0.1'; parent::__construct(); $this->page = basename(__FILE__,'.php'); $this->displayName = $this->l('Modulo Base'); $this->description = $this->l('Modulo Base'); } public function install(){ if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentTop')) return false; return true; } public function uninstall() { // Uninstall Module if (!parent::uninstall()) return false; return true; } public function hookPayment($params) { echo "debug"; exit; } public function hookPaymentTop($params) { //echo "debugtop"; //exit; } } Well, in theory after install this module, when you arrive to the choosing payment part, this should print "debug" and exit... but it doesn't.I have registered it also in the PaymentTop hook to try if this is working. When I delete the comment, it appear "debugtop" and exit...I'm desesperate... I don't know what's wrong... in DDBB the module it correctly inserted and also, in the module position in back office, I can change the position...I also took a look to the paypal module, changing the function hookPayment(with echo and exit), and it entered there, so I don't know what happening to my module. Any ideas of what s wrong? Link to comment Share on other sites More sharing options...
cinopower Posted February 6, 2014 Author Share Posted February 6, 2014 Still more weird stuff...I have made a copy of the whole web and database in my local machine and the new module I created is working.I'm totally lost... Of course, I know I can create another hook, set this hook in the tpl file, wherever I want, and just register my new module to this hook. But I want to know whats happening the this hook and why stop working for new modules. Link to comment Share on other sites More sharing options...
tarek.fellah Posted February 6, 2014 Share Posted February 6, 2014 Hi, may be your methods should return something, try with return 'debug'; Link to comment Share on other sites More sharing options...
cinopower Posted February 6, 2014 Author Share Posted February 6, 2014 Hi, thank you for posting.It have nothing to do with return sentences, the 'exit' should come first, and as I said, in local, the same code are working perfectly.Anyway, I have added the 'return' and nothing changed. Link to comment Share on other sites More sharing options...
tarek.fellah Posted February 6, 2014 Share Posted February 6, 2014 In hook payment you should call your tpl file like this return $this->fetchTemplate('yourtpltpl'); Link to comment Share on other sites More sharing options...
cinopower Posted February 6, 2014 Author Share Posted February 6, 2014 Hi, and thank you again.I think I didn't explain myself properly...I know i have to call my tpl file in the return, but the point is that it doesn't matter what I write in hook payment, nothing is readed. Actually, if I put "exit" the execution should stop, whatever return it's there after that (I put "exit" just to know if it was entering there).For example, if I make the same test in paypal module and I write "exit;" in the first line of the payment hook in this module, when I arrive to the payment methods page, the web stops in a blank page... Link to comment Share on other sites More sharing options...
cinopower Posted February 12, 2014 Author Share Posted February 12, 2014 Well, I answer myself just in case someone have a similar problem.The thing is that the behavior of the payment hook is a bit different to the others hooks.In class Hook there are some methods to place the modules registered. La function "exec" call to "getHookModuleExecList", that return a list of available modules for a hook. With the payment modules there are some extra checkings (tables "module_currency" and "module_country").In my case, I had somes errors at the table "module_currency"(I really don't know why, I think it was a mistake on creating different currencies for my shop) and this method never returned my module in the list, so it was never created the instance and never called the hookpayment function. 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