You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/discounts/extend_discounts_wizard.md
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ month_change: true
12
12
13
13
For the store managers to use your [custom conditions and rules](extend_discounts.md#create-custom-conditions), you need to integrate them into the back office discounts creation form.
14
14
15
-
This form is built using [Symfony Forms]([[= symfony_doc=]]/forms.html) and the [`DiscountFormMapperInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html)is the core of the implementation.
15
+
This form is built using [Symfony Forms]([[= symfony_doc=]]/forms.html) and the [`DiscountFormMapperInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html)interface is at the core of the implementation.
16
16
17
17
It provides a two-way mapping between the form structures (used to render the form) and the PHP API values used to create the discounts by offering methods related to:
18
18
@@ -38,7 +38,7 @@ See [discount's form events](discounts_events.md#form-events) for a list of the
38
38
## Integrate custom conditions
39
39
40
40
This example continues the [anniversary discount condition example](extend_discounts.md#implement-custom-condition), integrating the condition with the wizard by adding a dedicated step with condition options.
41
-
The condition will be limited to cart discounts only.
41
+
The new step will be limited to cart discounts only.
42
42
43
43
To add a custom step, create a value object representing the step.
44
44
It contains the step identifier, properties for storing form data, and extends the [`AbstractDiscountStep`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-AbstractDiscountStep.html):
@@ -107,18 +107,16 @@ The custom condition is now integrated with the discounts wizard and can be used
107
107
108
108
This example continues the [purchasing power parity rule example](extend_discounts.md#implement-custom-rules), integrating the rule with the wizard.
109
109
110
-
First, we need to create a new service implementing the `DiscountValueMapperInterface` interface, responsible for handling the new rule type:
110
+
First, create a new service implementing the `DiscountValueMapperInterface` interface, responsible for handling the new rule type:
This value mapper is used by a new form mapper, dedicated to the new rule type:
@@ -155,3 +153,13 @@ and add a dedicated value type class:
155
153
156
154
In the example above, the discount value step is used to to display a read-only field with regions the discount is limited to.
157
155
The `$availableRegionHandler` callback function extracts the selected regions and modifies the form as needed, using the `FormEvents::PRE_SET_DATA` and `FormEvents::POST_SUBMIT` events.
156
+
157
+
The last step consists of providing all the required translations.
158
+
Specify them in `translations/ibexa_discount.en.yaml`:
159
+
160
+
``` yaml
161
+
ibexa.discount.type.purchasing_power_parity: Purchasing Power Parity
162
+
discount.rule_type.purchasing_power_parity: Purchasing Power Parity
163
+
```
164
+
165
+
The custom rule is now integrated with the discounts wizard and can be used by store managers to offer new discounts.
0 commit comments