Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
74 changes: 74 additions & 0 deletions docs/api/event_reference/discounts_events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---

Check warning on line 1 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L1

[Ibexa.ReadingLevel] The grade level is 8.78. Aim for 8th grade or lower by using shorter sentences and words.
Raw output
{"message": "[Ibexa.ReadingLevel] The grade level is 8.78. Aim for 8th grade or lower by using shorter sentences and words.", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}
description: Events that are triggered when working with discounts.
page_type: reference
editions:
- lts-update
- commerce
month_change: true
---

# Discounts events

## Discount management

The events below are dispatched when managing [discounts](discounts_guide.md):

| Event | Dispatched by |
|---|---|
|[BeforeCreateDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeCreateDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html)
|[CreateDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html)
|[BeforeDeleteDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeDeleteDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html)
|[DeleteDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-DeleteDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html)
|[BeforeUpdateDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeUpdateDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html)|
|[UpdateDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-UpdateDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html)|

## Form events

### Form

The events below allow you to customize the discounts creation wizard:

| Event | Dispatched by |
|---|---|
|[CreateDiscountCreateStructEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateDiscountCreateStructEvent.html) | [DiscountFormMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html)|
|[CreateDiscountUpdateStructEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateDiscountUpdateStructEvent.html) | [DiscountFormMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html)|
|[CreateFormDataEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateFormDataEvent.html) | [DiscountFormMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html)|
|[MapDiscountToFormDataEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-MapDiscountToFormDataEvent.html) | [DiscountFormMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html) |

### Form steps

The following events are dispatched when rendering each step of the discount wizard, allowing you to add new fields to it:

| Event | Event name |
|---|---|
|[CreateFormDataEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-CreateFormDataEvent.html)| `ibexa.discounts.form_mapper.<step_identifier>.create_form_data`|

Check failure on line 44 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L44

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 44, "column": 63}}}, "severity": "ERROR"}
|[MapCreateDataToStructEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-MapCreateDataToStructEvent.html)|`ibexa.discounts.form_mapper.<step_identifier>.map_create_data_to_struct`|

Check failure on line 45 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L45

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 45, "column": 70}}}, "severity": "ERROR"}
|[MapDiscountToFormDataEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-MapDiscountToFormDataEvent.html)| `ibexa.discounts.form_mapper.<step_identifier>.map_discount_to_form_data`|

Check failure on line 46 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L46

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 46, "column": 70}}}, "severity": "ERROR"}
|[MapUpdateDataToStructEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-MapUpdateDataToStructEvent.html)|`ibexa.discounts.form_mapper.<step_identifier>.map_update_data_to_struct `|

Check failure on line 47 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L47

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 47, "column": 70}}}, "severity": "ERROR"}

The event classes are shared between steps, but they are dispatched with different names.
Each step form mapper dispatches its own set of events.

| Form mapper | Step identifier |
|---|---|
| [ConditionsMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-ConditionsMapperInterface.html)| [`conditions`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-ConditionsInterface.html#constant_IDENTIFIER) |

Check failure on line 54 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L54

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 54, "column": 70}}}, "severity": "ERROR"}
| [GeneralPropertiesMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-GeneralPropertiesMapperInterface.html)| [`general_properties`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-GeneralPropertiesInterface.html#constant_IDENTIFIER) |

Check failure on line 55 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L55

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 55, "column": 77}}}, "severity": "ERROR"}

Check failure on line 55 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L55

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 55, "column": 222}}}, "severity": "ERROR"}
| [ProductConditionsMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-ProductConditionsMapperInterface.html)| [`products`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-ProductConditionInterface.html#constant_IDENTIFIER) |

Check failure on line 56 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L56

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 56, "column": 212}}}, "severity": "ERROR"}
| [UserConditionsMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-UserConditionsMapperInterface.html)| [`target_group`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-UserConditionInterface.html#constant_IDENTIFIER) |

Check failure on line 57 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L57

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 57, "column": 210}}}, "severity": "ERROR"}

### Back office

These events are dispatched by the back office controllers after user chooses the "Save" action when creating or updating a discount.

| Event | Dispatched by | Description |
|---|---|---|
[PreDiscountCreateEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountCreateEvent.html) | `Ibexa\Bundle\Discounts\Controller\DiscountCreateController` | Dispatched when the discount creation is finished in the back office form |

Check failure on line 65 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L65

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 65, "column": 65}}}, "severity": "ERROR"}
[PreDiscountUpdateEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountUpdateEvent.html) | `Ibexa\Bundle\Discounts\Controller\DiscountEditController` | Dispatched when the discount modifications is finished in the back office form |

Check failure on line 66 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L66

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 66, "column": 65}}}, "severity": "ERROR"}

## Discount codes

The event below allows you to inject your custom logic before the discount code is applied to a product in cart:

| Event | Dispatched by | Description |
|---|---|---|
|[BeforeDiscountCodeApplyEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Event-BeforeDiscountCodeApplyEvent.html)|`Ibexa\Bundle\DiscountsCodes\Controller\REST\DiscountCodeController`| Dispatched before a discount code is applied in the cart |

Check failure on line 74 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L74

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 74, "column": 72}}}, "severity": "ERROR"}
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ nav:
- Trash events: api/event_reference/trash_events.md
- Twig Components: api/event_reference/twig_component_events.md
- AI Action events: api/event_reference/ai_action_events.md
- Discounts events: api/event_reference/discounts_events.md
- Other events: api/event_reference/other_events.md
- Administration:
- Administration: administration/administration.md
Expand Down