Jump to content

How To Use Hook Displayproductpriceblock With Type Old_Price


Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

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

  • 2 years later...

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.

 

  • Like 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...