marck.prinsloo Posted January 11, 2016 Share Posted January 11, 2016 Hi I'm developing a custom module that should show a new price underneath the standard price. I found a hook that should work (displayProductPriceBlock ) and it does but it runs my tpl file for every type of this hook. How can I specifically choose to only display it at {hook h="displayProductPriceBlock" product=$product type="price"} and not at {hook h="displayProductPriceBlock" product=$product type="unit_price"} Thank you. Link to comment Share on other sites More sharing options...
roja45 Posted January 11, 2016 Share Posted January 11, 2016 The hook in your module will run on everytime, regardless, so in your module check the type variable and if it isn't the one you want just return out of the hook without loading your template. 1 Link to comment Share on other sites More sharing options...
marck.prinsloo Posted January 12, 2016 Author Share Posted January 12, 2016 Thank you for the reply. How do I check the type variable? Link to comment Share on other sites More sharing options...
roja45 Posted January 12, 2016 Share Posted January 12, 2016 it'll be passed in as a parameter to the hook. without checking I'm not sure what exactly it'll be, something like $params['type'] I would guess. Easiest way would be to attach a debugger and have a look, or print_r($params) in your hook code. 1 Link to comment Share on other sites More sharing options...
marck.prinsloo Posted January 13, 2016 Author Share Posted January 13, 2016 thank you roja45, it was $params['type'] exactly as you said . I appreciate your help. 1 Link to comment Share on other sites More sharing options...
NearEarthObject Posted January 18, 2017 Share Posted January 18, 2017 Hi ! Facing same issue with default boostrap template 1.6.1.11 , the hook appears 2 times for each type depending of grid/list on displayList true or false. So the hook is duplicate two times, some jquery function targeting some specific id fall in true mess... So the solution belongs in turning id in class but that's not a clean way to deal with... Link to comment Share on other sites More sharing options...
UniArt Posted June 3, 2019 Share Posted June 3, 2019 I have had the same difficulty but with version 1.7 and I have solved it in this way: public function renderWidget($hookName = null, array $configuration = []) { if (!$this->isCached($this->templateFile, $this->getCacheId('ivainfo'))) { $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); } if ( $hookName == 'displayProductPriceBlock' && $configuration['type'] != 'price') { return false; } return $this->fetch($this->templateFile, $this->getCacheId('ivainfo')); } So when the hook is 'displayProductPriceBlock' but not of the "price" type, the whidget will not be displayed. I know it's an old post, but maybe others are also looking for a similar solution. 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