Prestashop: Hook position not inserted in ps_hook table by default

Created on 18 Sep 2019  Â·  11Comments  Â·  Source: PrestaShop/PrestaShop

Describe the bug
There's hook displayCheckoutSummaryTop at /themes/classic/templates/checkout/_partials/cart-summary.tpl template.

This hook is not in ps_hook table, so it doesn't appear in the dropdown at Design -> Positions -> Transplant a module and therefore can not be inserted.

To Reproduce

  1. Add the following function to a module:
public function hookDisplayCheckoutSummaryTop()
{
    return true;
}
  1. Go to Design -> Positions -> Transplant a module
  2. Select module and check Available hooks. displayCheckoutSummaryTop is not displayed.

Additional information
PrestaShop version: 1.7.6.1

1.7.5.2 1.7.6.0 1.7.6.1 Bug Front-end Modules Positions To Do Trivial

Most helpful comment

All 11 comments

Fix
Execute the following query:

`INSERT INTO `ps_hook` (`name`, `title`, `description`, `position`)
VALUES ('displayCheckoutSummaryTop', '', NULL, '1');`

Where could this be added to be executed in the upgrading scripts?

Hi @idnovate,

I did not manage to reproduce the issue with PS1.7.6.1.

public function hookDisplayCheckoutSummaryTop()
{
    return true;
}

I just added this function into a module & I reset it.
image

Thanks to check & feedback.

Have you used registerHook('displayCheckoutSummaryTop')?

@idnovate, yes!

Hehe this function inserts the hook when it doesn't exist :) Please just add function hookDisplayCheckoutSummaryTop() to a new or existing module and don't register it on install.

@idnovate, the module does not do much. In order to display something on the front office, we have to add support for a few hooks. This is done by implementing the hooks’ methods, and that was actually done in the install() method we wrote earlier, using the registerHook() method.

Thanks!

This is not how it works. It's inconsistent. Test the following:

  1. Add both functions to a module:
public function hookDisplayCheckoutSummaryTop()
{
    return true;
}

public function hookDisplayCartExtraProductActions()
{
    return true;
}
  1. Go to Design -> Positions -> Transplant a module
  2. Check that you can transplant DisplayCartExtraProductActions but no DisplayCheckoutSummaryTop.

The dropdown check which hooks are defined in the module and display them in the dropdown. This has been working this way always, there wasn't the need to register the hook in the install to transplant a module into a hook.

The problem is that DisplayCheckoutSummaryTop is not in ps_hook table.

@idnovate, I tried with those two functions & those two hooks are displayed.
image

Thanks!

  1. Install this module
    dummymodule.zip
  2. Go to Design -> Positions -> Transplant a module
  3. Select dummymodule
  4. Check available hooks. It should appear both DisplayCheckoutSummaryTop and DisplayCartExtraProductActions hooks but it doesn't. DisplayCheckoutSummaryTop is not displayed.

image

Please test it in a different store, as you have previously registered hook DisplayCheckoutSummaryTop so it's in your ps_hook table and you won't be able to reproduce it.

@idnovate, thanks for this clarifications.
I manage to reproduce the issue with PS1.7.6.0 & PS1.7.5.2
I’ll add this to the debug roadmap so that it’s fixed. If you have already fixed it on your end or if you think you can do it, please do send us a pull request!
Thanks!

Was this page helpful?
0 / 5 - 0 ratings