{"id":1472,"date":"2015-06-22T07:47:57","date_gmt":"2015-06-22T07:47:57","guid":{"rendered":"https:\/\/prestawebdev.newsoftdemo.info\/blog\/?p=1472"},"modified":"2022-01-11T11:56:23","modified_gmt":"2022-01-11T11:56:23","slug":"how-to-create-a-custom-hook-in-prestashop","status":"publish","type":"post","link":"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/","title":{"rendered":"How to create a custom hook in PrestaShop?"},"content":{"rendered":"<p>Hooks are gaining importance in <strong><a href=\"https:\/\/prestawebdev.newsoftdemo.info\/prestashop-module-development\">PrestaShop shopping cart development<\/a> day by day<\/strong> as they allow you to add additional functionality at specific points. Today I\u2019ll teach you how to create custom hooks in your <strong>PrestaShop module<\/strong>.<br \/>\nUse below steps:<br \/>\n<strong>1. Register your hook using function. Place this function\u00a0into install section.<\/strong><br \/>\n  $this->registerHook(&#8216;displayCustomHtmlContent&#8217;);<\/p>\n<p><strong>2. Create hook function.<\/strong><\/p>\n<p> \/**<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0 * Add the custom content on front<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0 *\/<br \/>\n\u00a0\u00a0\u00a0\u00a0 public function hookDisplayCustomHtmlContent()<br \/>\n\u00a0\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $custom_html = Configuration::get(&#8216;CUSTOMHOOK_CONTENT&#8217;);<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $this->context->smarty->assign(&#8216;custom_html&#8217;, $custom_html);<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $this->smarty->assign(<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 array(<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8216;custom_html_test&#8217; => $custom_html<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 )<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 );<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return $this->display(__FILE__, &#8216;customhook.tpl&#8217;);<br \/>\n\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p><a href=\"https:\/\/prestawebdev.newsoftdemo.info\/blog\/\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/prestawebdev.newsoftdemo.info\/blog\/wp-content\/uploads\/2015\/06\/Prestashop-Developers.png\" alt=\"Prestashop-Developers\" width=\"968\" height=\"388\" class=\"aligncenter size-full wp-image-1473\" \/><\/a><\/p>\n<p><strong>3. Display your code anywhere on any tpl using below function.<\/strong><\/p>\n<p> {hook h=&#8217;displayCustomHtmlContent&#8217;}<\/p>\n<p><a href=\"https:\/\/prestawebdev.newsoftdemo.info\/blog\/\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/prestawebdev.newsoftdemo.info\/blog\/wp-content\/uploads\/2015\/06\/Prestashop.png\" alt=\"Prestashop\" width=\"968\" height=\"388\" class=\"aligncenter size-full wp-image-1474\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019ll teach you how to create custom hooks in your PrestaShop module. Use below steps: 1. Register your hook using function. Place this function\u00a0into install section. $this->registerHook(&#8216;displayCustomHtmlContent&#8217;); 2. Create hook function. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[55],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Develop a custom Hook for your PrestaShop store<\/title>\n<meta name=\"description\" content=\"Creating custom Hooks is extremely easy in PrestaShop and just requires you to use some simple steps.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Develop a custom Hook for your PrestaShop store\" \/>\n<meta property=\"og:description\" content=\"Creating custom Hooks is extremely easy in PrestaShop and just requires you to use some simple steps.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/\" \/>\n<meta property=\"og:site_name\" content=\"prestawebdeveloper\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-22T07:47:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-11T11:56:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prestawebdev.newsoftdemo.info\/blog\/wp-content\/uploads\/2015\/06\/Prestashop-Developers.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/\",\"url\":\"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/\",\"name\":\"Develop a custom Hook for your PrestaShop store\",\"isPartOf\":{\"@id\":\"https:\/\/www.prestawebdeveloper.com\/blog\/#website\"},\"datePublished\":\"2015-06-22T07:47:57+00:00\",\"dateModified\":\"2022-01-11T11:56:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.prestawebdeveloper.com\/blog\/#\/schema\/person\/679ef4596888e4b2d4e38a759d449820\"},\"description\":\"Creating custom Hooks is extremely easy in PrestaShop and just requires you to use some simple steps.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.prestawebdeveloper.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create a custom hook in PrestaShop?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.prestawebdeveloper.com\/blog\/#website\",\"url\":\"https:\/\/www.prestawebdeveloper.com\/blog\/\",\"name\":\"prestawebdeveloper\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.prestawebdeveloper.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.prestawebdeveloper.com\/blog\/#\/schema\/person\/679ef4596888e4b2d4e38a759d449820\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.prestawebdeveloper.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4c9961498f3d5b56a1a752fb710b65b7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4c9961498f3d5b56a1a752fb710b65b7?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\/\/www.prestawebdeveloper.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Develop a custom Hook for your PrestaShop store","description":"Creating custom Hooks is extremely easy in PrestaShop and just requires you to use some simple steps.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/","og_locale":"en_US","og_type":"article","og_title":"Develop a custom Hook for your PrestaShop store","og_description":"Creating custom Hooks is extremely easy in PrestaShop and just requires you to use some simple steps.","og_url":"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/","og_site_name":"prestawebdeveloper","article_published_time":"2015-06-22T07:47:57+00:00","article_modified_time":"2022-01-11T11:56:23+00:00","og_image":[{"url":"https:\/\/prestawebdev.newsoftdemo.info\/blog\/wp-content\/uploads\/2015\/06\/Prestashop-Developers.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/","url":"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/","name":"Develop a custom Hook for your PrestaShop store","isPartOf":{"@id":"https:\/\/www.prestawebdeveloper.com\/blog\/#website"},"datePublished":"2015-06-22T07:47:57+00:00","dateModified":"2022-01-11T11:56:23+00:00","author":{"@id":"https:\/\/www.prestawebdeveloper.com\/blog\/#\/schema\/person\/679ef4596888e4b2d4e38a759d449820"},"description":"Creating custom Hooks is extremely easy in PrestaShop and just requires you to use some simple steps.","breadcrumb":{"@id":"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.prestawebdeveloper.com\/blog\/how-to-create-a-custom-hook-in-prestashop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.prestawebdeveloper.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to create a custom hook in PrestaShop?"}]},{"@type":"WebSite","@id":"https:\/\/www.prestawebdeveloper.com\/blog\/#website","url":"https:\/\/www.prestawebdeveloper.com\/blog\/","name":"prestawebdeveloper","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.prestawebdeveloper.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.prestawebdeveloper.com\/blog\/#\/schema\/person\/679ef4596888e4b2d4e38a759d449820","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.prestawebdeveloper.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4c9961498f3d5b56a1a752fb710b65b7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4c9961498f3d5b56a1a752fb710b65b7?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/www.prestawebdeveloper.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/posts\/1472"}],"collection":[{"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/comments?post=1472"}],"version-history":[{"count":1,"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/posts\/1472\/revisions"}],"predecessor-version":[{"id":2361,"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/posts\/1472\/revisions\/2361"}],"wp:attachment":[{"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/media?parent=1472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/categories?post=1472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.prestawebdeveloper.com\/blog\/wp-json\/wp\/v2\/tags?post=1472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}