ComGrafPL Posted February 23, 2022 Share Posted February 23, 2022 (edited) Can't change module position on product page. I have a module "Ask a question" one. For weird reasons, i can't place it in desired position. I have try with hooks like i normal do. But it seems i can only move it above or below social media buttons. Any clue how to move it below add to cart place? PHP 7.4 / PS 1.7.8.3 Thanks Edited February 23, 2022 by ComGrafPL (see edit history) 1 Link to comment Share on other sites More sharing options...
ps8modules Posted February 23, 2022 Share Posted February 23, 2022 (edited) Hi. Is this the default template? ./themes/classic/templates/catalog/_partials/product-add-to-cart.tpl {hook h='displayProductActions' product=$product} Edited February 23, 2022 by 4you.software (see edit history) Link to comment Share on other sites More sharing options...
ComGrafPL Posted February 23, 2022 Author Share Posted February 23, 2022 Its a custom theme. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted February 23, 2022 Share Posted February 23, 2022 (edited) And module: public function hookDisplayProductActions(array $params) { if('product' == $this->context->controller->php_self){ $idProduct = Tools::getValue('id_product'); $myParams = 'Hello Word !'; $this->smarty->assign('myParams', $myParams); return $this->display(__FILE__, 'views/templates/front/my_module.tpl'); } } And my_module.tpl: {block name='my_module'} <hr> <div class="my_module_class"> <div class="clearfix" style="display:flex;"> <div class="my-btn">{$myParams}</div> </div> </div> {/block} Edited February 23, 2022 by 4you.software (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted February 23, 2022 Share Posted February 23, 2022 Check if HOOK exists in product-add-to-cart.tpl: 1 Link to comment Share on other sites More sharing options...
ComGrafPL Posted February 23, 2022 Author Share Posted February 23, 2022 17 minutes ago, 4you.software said: Check if HOOK exists in product-add-to-cart.tpl: Hook is there. After adding code to module, getting error 500. Link to comment Share on other sites More sharing options...
ps8modules Posted February 23, 2022 Share Posted February 23, 2022 (edited) Enable debug mode. That was just a sample of me. I don't have the code verified. Edited February 23, 2022 by 4you.software (see edit history) 1 Link to comment Share on other sites More sharing options...
ComGrafPL Posted February 23, 2022 Author Share Posted February 23, 2022 14 minutes ago, 4you.software said: Enable debug mode. Hook is there. Added public function hookDisplayProductActions($params) to module. No 500 error. Module still on same position. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted February 23, 2022 Share Posted February 23, 2022 (edited) Another option with inserting your own hook. It's terribly simple. Just understand it. Open up ./themes/classic/templates/catalog/product.tpl 1. find {block name='product_add_to_cart'} {include file='catalog/_partials/product-add-to-cart.tpl'} {/block} 2. add after your block or hook {block name='my_module'} {hook h='myCustomDisplayButton' id_product=$product.id} {/block} 3. edit your module and add your hook a) edit install function public function install() { $this->registerHook('myCustomDisplayButton'); .... .... .... b) edit uninstall function public function uninstall() { $this->unregisterHook('myCustomDisplayButton'); .... .... .... c) add your hook function public function hookMyCustomDisplayButton($params) { $idProduct = $params; return '<hr><div style="display:block; width:100%;"><div class="btn btn-primary" style="my-button">Hello Word !</div></div>'; } 4. register your hook - admin => design => positions and click to Transplant a module button 5. find your module 6. select your new HOOK Result: Edited February 23, 2022 by 4you.software (see edit history) 1 Link to comment Share on other sites More sharing options...
ps8modules Posted February 23, 2022 Share Posted February 23, 2022 After each modification it is necessary to clean the Cache !!! 1 Link to comment Share on other sites More sharing options...
ComGrafPL Posted February 23, 2022 Author Share Posted February 23, 2022 2 hours ago, 4you.software said: After each modification it is necessary to clean the Cache !!! Will try it later on. This theme is a real pain. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted February 23, 2022 Share Posted February 23, 2022 Creating your own hook and paste it into TPL template is a job for two minutes 🤪 1 Link to comment Share on other sites More sharing options...
ComGrafPL Posted February 23, 2022 Author Share Posted February 23, 2022 2 hours ago, 4you.software said: Creating your own hook and paste it into TPL template is a job for two minutes 🤪 Last step gets me error: Parse error: syntax error, unexpected '$product' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST) On line: $product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id); But i haven't edit this line, so not sure. 1 Link to comment Share on other sites More sharing options...
Piotr3qx Posted February 23, 2022 Share Posted February 23, 2022 (edited) Maybe there is some random JavaScript code that copies the html of displayProductActions hook and paste under title? Have this situation once... Check in html source code (not dev tools) if the code of this module is below the title Edited February 23, 2022 by Piotr3qx (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted February 23, 2022 Share Posted February 23, 2022 (edited) 1 hour ago, ComGrafPL said: Last step gets me error: Parse error: syntax error, unexpected '$product' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST) On line: $product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id); But i haven't edit this line, so not sure. I asked you if you have a default "classic" template. you said yes. It's not true. You are using another template. Do you use warehouse theme? You need to show us the product.tpl file Edited February 23, 2022 by 4you.software (see edit history) 1 Link to comment Share on other sites More sharing options...
ComGrafPL Posted February 23, 2022 Author Share Posted February 23, 2022 After hell of the fight. Solved by @4you.software Thank you. 1 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