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/discounts_api.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,15 +14,15 @@ By integrating with the [Discount feature](discounts_guide.md) you can automate
14
14
15
15
For example, you can automatically create a discount when a customer places their 3rd order, encouraging them to make another purchase and increase their chances of becoming a local customer.
16
16
17
-
You can manage discounts using [data migrations](importing_data.md#discounts), [REST API](/api/rest_api/rest_api_reference/rest_api_reference.html#discounts), or the PHP API by using the [Ibexa\Contracts\Discounts\DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html) service.
17
+
You can manage discounts using [data migrations](importing_data.md#discounts), [REST API](/api/rest_api/rest_api_reference/rest_api_reference.html#discounts), or the PHP API by using the [`Ibexa\Contracts\Discounts\DiscountServiceInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html) service.
18
18
19
19
The core concepts when working with discounts through the APIs are listed below.
20
20
21
21
### Types
22
22
23
23
When using the PHP API, the discount type defines where the discount can be applied.
24
24
25
-
Discounts are applied in two places, listed in the [DiscountType](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-DiscountType.html) class:
25
+
Discounts are applied in two places, listed in the [`DiscountType`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-DiscountType.html) class:
26
26
27
27
-**Product catalog** - `catalog` discounts are activated when browsing the product catalog and do not require any action from the customer to be activated
28
28
-**Cart** - `cart` discounts can activate when entering the [cart](cart.md), if the right conditions are met. They may also require entering a discount code to be activated
@@ -31,7 +31,7 @@ Regardless of activation place, discounts always apply to products and reduce th
31
31
32
32
To define when a discount activates and how the price is reduced, use rules and conditions.
33
33
They make use of the [Symfony Expression language]([[= symfony_doc=]]//components/expression_language.html).
34
-
Use the expression values provided below when using data migrations or the REST API to pass the right values.
34
+
Use the expression values provided below when using data migrations or when parsing REST API responses.
35
35
36
36
### Rules
37
37
@@ -40,8 +40,8 @@ The following discount rule types are available:
40
40
41
41
| Rule type | Identifier | Description | Expression value |
42
42
|---|---|---|---|
43
-
|`Ibexa\Discounts\Value\DiscountRule\FixedAmount`|`fixed_amount`| Deducts the specified amount, for example 10 EUR, from the base price |`discount_amount`|
44
-
|`Ibexa\Discounts\Value\DiscountRule\Percentage`|`percentage`| Deducts the specified percentage, for example -10%, from the base price |`discount_percentage`|
43
+
|`Ibexa\Discounts\Value\DiscountRule\FixedAmount`|<nobr>`fixed_amount`</nobr>| Deducts the specified amount, for example <nobr>10 EUR</nobr>, from the base price |<nobr>`discount_amount`</nobr>|
44
+
|`Ibexa\Discounts\Value\DiscountRule\Percentage`|<nobr>`percentage`</nobr>| Deducts the specified percentage, for example -10%, from the base price |<nobr>`discount_percentage`</nobr>|
45
45
46
46
Only a single discount can be applied to a given product, and a discount can only have a single rule.
47
47
@@ -90,13 +90,13 @@ The discount has four properties that can be translated:
90
90
| Promotion label | Information displayed to customers |
91
91
| Promotion description | Information displayed to customers |
92
92
93
-
Use the [DiscountTranslationStruct](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Struct-DiscountTranslationStruct.html) to provide translations for discounts.
93
+
Use the [`DiscountTranslationStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Value-Struct-DiscountTranslationStruct.html) to provide translations for discounts.
94
94
95
95
### Discount codes
96
96
97
97
To activate a cart discount only after a proper discount code is provided, you need to:
98
98
99
-
1. Create a discount code using the [DiscountCodeServiceInterface::createDiscountCode()](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-DiscountCodeServiceInterface.html#method_createDiscountCode) method
99
+
1. Create a discount code using the [`DiscountCodeServiceInterface::createDiscountCode()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-DiscountCodeServiceInterface.html#method_createDiscountCode) method
100
100
1. Attach it to a discount by using the `IsValidDiscountCode` condition
101
101
102
102
Set the [`usedLimit`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Value-Struct-DiscountCodeCreateStruct.html#method___construct) property to the number of times a single customer can use this code, or to `null` to make the usage unlimited.
@@ -107,12 +107,13 @@ The [`DiscountCodeServiceInterface::registerUsage()`](/api/php_api/php_api_refer
107
107
108
108
The example below contains a Command creating a cart discount. The discount:
109
109
110
-
- has the highest possible priority value
111
-
- deducts 10 EUR from the base price of the product
112
-
- is permanent
113
-
- is valid in Germany and France
114
-
- applies to 2 products
115
-
- requires a `summer10` discount code to be activated. The code can be used unlimited number of times
110
+
- has the highest possible [priority](#priority) value
111
+
-[rule](#rules) deducts 10 EUR from the base price of the product
112
+
- is [permanent](#start-and-end-date)
113
+
-[depends](#conditions) on
114
+
- being bought from Germany or France
115
+
- 2 products
116
+
- a `summer10`[discount code](#discount-codes) which can be used unlimited number of times
@@ -122,7 +123,7 @@ Similarly, use the `deleteDiscount`, `deleteTranslation`, `disableDiscount`, `en
122
123
123
124
## Search
124
125
125
-
You can search for Discounts using the [`DiscountServiceInterface::findDiscounts()](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_findDiscounts) method.
126
+
You can search for Discounts using the [`DiscountServiceInterface::findDiscounts()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_findDiscounts) method.
126
127
To learn more about the available search options, see Discounts' [Search Criteria](discounts_criteria.md) and [Sort Clauses](discounts_sort_clauses.md).
127
128
128
129
For discount codes, you can query the database for discount code usage using [`DiscountCodeServiceInterface::findCodeUsages()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-DiscountCodeServiceInterface.html#method_findCodeUsages) and [`DiscountCodeUsageQuery`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Value-Query-DiscountCodeUsageQuery.html).
0 commit comments