How to create a custom hook in PrestaShop?

[DISPLAY_ULTIMATE_SOCIAL_ICONS]

Hooks are gaining importance in PrestaShop shopping cart development day by day as they allow you to add additional functionality at specific points. Today I’ll teach you how to create custom hooks in your PrestaShop module.
Use below steps:
1. Register your hook using function. Place this function into install section.
$this->registerHook(‘displayCustomHtmlContent’);

2. Create hook function.

/**
      * Add the custom content on front
      */
     public function hookDisplayCustomHtmlContent()
     {
         $custom_html = Configuration::get(‘CUSTOMHOOK_CONTENT’);
         $this->context->smarty->assign(‘custom_html’, $custom_html);
         $this->smarty->assign(
             array(
                 ‘custom_html_test’ => $custom_html
             )
         );
         return $this->display(__FILE__, ‘customhook.tpl’);
     }

Prestashop-Developers

3. Display your code anywhere on any tpl using below function.

{hook h=’displayCustomHtmlContent’}

Prestashop

Related Post

  • Top 5 Future Trends to Assure your eCommerce Success

    The world of eCommerce is changing and evolving. What was once a small niche market has now exploded into an industry worth over $4 trillion! Yet every evolution comes with new challenges, it’s on you how you keep up with them? The answer shouldn’t be by having just certified Prestashop developers or Magento commerce experts on […]

    Read More
  • PrestaShop 1.7: A Great Platform For Continued Digital Commerce Growth

    PrestaShop was launched in 2007, and the platform has supported the eCommerce needs of almost 250,000 active stores across nearly 190 countries. This platform’s concept is based on the localization and to develop highly versatile eCommerce stores for mid-sized to large online companies. Moreover, it will help you to churn out your eCommerce portal in […]

    Read More

Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/prestawebdev/public_html/blog/wp-includes/functions.php on line 5107