Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document missing hooks on V8 #1594

Merged
merged 3 commits into from
Jan 16, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
menuTitle: action<DefinitionId>GridDataModifier
Title: action<DefinitionId>GridDataModifier
hidden: true
hookTitle:
files:
- src/Core/Grid/GridFactory.php
locations:
- front office
- back office
type: action
hookAliases:
---

# Hook action&lt;DefinitionId>GridDataModifier

## Information

Hook locations:
- front office
- back office

Hook type: action

Located in:
- [src/Core/Grid/GridFactory.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Grid/GridFactory.php)

## Call of the Hook in the origin file

```php
$this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($definition->getId()) . 'GridDataModifier', [
'data' => &$data,
]);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
menuTitle: action<DefinitionId>GridDefinitionModifier
Title: action<DefinitionId>GridDefinitionModifier
hidden: true
hookTitle:
files:
- src/Core/Grid/Definition/Factory/AbstractGridDefinitionFactory.php
locations:
- front office
- back office
type: action
hookAliases:
---

# Hook action&lt;DefinitionId>GridDefinitionModifier

## Information

Hook locations:
- front office
- back office

Hook type: action

Located in:
- [src/Core/Grid/Definition/Factory/AbstractGridDefinitionFactory.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Grid/Definition/Factory/AbstractGridDefinitionFactory.php)

## Call of the Hook in the origin file

```php
$this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($definition->getId()) . 'GridDefinitionModifier', [
'definition' => $definition,
]);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
menuTitle: action<DefinitionId>GridFilterFormModifier
Title: action<DefinitionId>GridFilterFormModifier
hidden: true
hookTitle:
files:
- src/Core/Grid/Filter/GridFilterFormFactory.php
locations:
- front office
- back office
type: action
hookAliases:
---

# Hook action&lt;DefinitionId>GridFilterFormModifier

## Information

Hook locations:
- front office
- back office

Hook type: action

Located in:
- [src/Core/Grid/Filter/GridFilterFormFactory.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Grid/Filter/GridFilterFormFactory.php)

## Call of the Hook in the origin file

```php
$this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($definition->getId()) . 'GridFilterFormModifier', [
'filter_form_builder' => $formBuilder,
]);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
menuTitle: action<DefinitionId>GridQueryBuilderModifier
Title: action<DefinitionId>GridQueryBuilderModifier
hidden: true
hookTitle:
files:
- src/Core/Grid/Data/Factory/DoctrineGridDataFactory.php
locations:
- front office
- back office
type: action
hookAliases:
---

# Hook action&lt;DefinitionId>GridQueryBuilderModifier

## Information

Hook locations:
- front office
- back office

Hook type: action

Located in:
- [src/Core/Grid/Data/Factory/DoctrineGridDataFactory.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Grid/Data/Factory/DoctrineGridDataFactory.php)

## Call of the Hook in the origin file

```php
$this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($this->gridId) . 'GridQueryBuilderModifier', [
'search_query_builder' => $searchQueryBuilder,
'count_query_builder' => $countQueryBuilder,
'search_criteria' => $searchCriteria,
]);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
menuTitle: action&lt;FormName>FormBuilderModifier
Title: action<FormName>FormBuilderModifier
hidden: true
hookTitle:
files:
- src/Core/Form/IdentifiableObject/Builder/FormBuilder.php
locations:
- front office
- back office
type: action
hookAliases:
---

# Hook action&lt;Object>FormBuilderModifier

## Information

{{% notice tip %}}
**Modify an identifiable object form content:**

This hook allows to modify an identifiable object forms content by modifying form builder data or FormBuilder itself.
Replace FormBuilderName by the identitiable object type.
{{% /notice %}}

Hook locations:
- back office
- front office

Hook type: action

Located in:
- [src/Core/Form/IdentifiableObject/Builder/FormBuilder.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Form/IdentifiableObject/Builder/FormBuilder.php)

## Call of the Hook in the origin file

```php
$this->hookDispatcher->dispatchWithParameters('action' . $this->camelize($formBuilder->getName()) . 'FormBuilderModifier', [
'form_builder' => $formBuilder,
'data' => &$data,
'options' => &$options,
'id' => $id
]);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
menuTitle: action<FormName>FormDataProviderData
Title: action<FormName>FormDataProviderData
hidden: true
hookTitle:
files:
- src/Core/Form/IdentifiableObject/Builder/FormBuilder.php
locations:
- front office
- back office
type: action
hookAliases:
---

# Hook action&lt;FormName>FormDataProviderData

## Information

Hook locations:
- front office
- back office

Hook type: action

Located in:
- [src/Core/Form/IdentifiableObject/Builder/FormBuilder.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Form/IdentifiableObject/Builder/FormBuilder.php)

## Call of the Hook in the origin file

```php
$this->hookDispatcher->dispatchWithParameters(
'action' . $this->camelize($this->getFormName()) . 'FormDataProviderData',
[
'data' => &$data,
'id' => $id,
'options' => &$options,
]
);
```
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ locations:
- front office
type: action
hookAliases:
hasExample: true
---

# Hook actionFilterDeliveryOptionList
@@ -42,9 +43,40 @@ Located in:

```php
Hook::exec(
'actionFilterDeliveryOptionList',
[
'delivery_option_list' => &$delivery_option_list,
]
)
'actionFilterDeliveryOptionList',
[
'delivery_option_list' => &$delivery_option_list,
]
)
```

## Example implementation

For example :

- a module can decide to display or not a certain carrier depending on the customer group
- a module can decide to block a means of delivery for a specific customer or group of customers
- a module can decide to display or not a carrier according to the date?

In this example, we disable the express delivery carrier on saturdays and sundays because our delivery promise of 24 hours cannot be satisfied:

```php
<?php
class MyCarrierConditionDisablerModule extends Module
{

public function install()
{
return parent::install() && $this->registerHook('actionFilterDeliveryOptionList');
}

public function hookActionCustomFilterDeliveryOptionList($params)
{
$deliveryOptionList = $params['delivery_option_list'];

if(0 == date('w') || 6 == date('w')){ // sundays or saturdays
// find carrier in $deliveryOptionList, and remove it
}
}
}
```
Original file line number Diff line number Diff line change
@@ -23,8 +23,7 @@ Aliases:

{{% notice tip %}}
**Post update of order status:**


Allows to be notified after an order status is changed.
kpodemski marked this conversation as resolved.
Show resolved Hide resolved
{{% /notice %}}

Hook locations: