官术网_书友最值得收藏!

Chapter 2. Hooks

A hook is the most essential concept to understand if you want to code a PrestaShop module, but as you will see, it's very easy.

Hooks are points on which you can attach modules in a way to change the normal behavior of the shop. In the PrestaShop 1.5/1.6 source code, their names are usually prefixed with display or action, depending on their purpose.

The display type hooks are generally used to add HTML or JS code on all or specific pages (for example, to add a block in a column, add an accessories link on a product page, add a field in a form, add information on a confirmation order page, and so on).

The action type hooks are used to change the behavior of the software by adding actions when events are triggered (for example, to add loyalty points to a customer when he or she places an order, logging modifications when a product is updated, send an e-mail to the merchant when a product is out of stock, and so on).

In this chapter, we will:

  • Register a module on a hook (to display comments form on the front office)
  • Use a database class (to register user comments in database)
  • Discover how hooks are triggered
  • Learn how to add new hooks
  • Learn how to use dynamic hooks
主站蜘蛛池模板: 花莲市| 曲麻莱县| 瑞安市| 三台县| 青田县| 汨罗市| 海丰县| 济南市| 佳木斯市| 苗栗市| 镇安县| 乐山市| 西城区| 苍梧县| 锡林浩特市| 三明市| 自治县| 安远县| 绥德县| 清涧县| 竹溪县| 白朗县| 龙井市| 昆明市| 大荔县| 阿巴嘎旗| 独山县| 太白县| 湾仔区| 山东| 昌宁县| 达孜县| 西乡县| 揭西县| 齐河县| 怀仁县| 海口市| 驻马店市| 望江县| 苏尼特左旗| 平舆县|