Skip to content

Commit 17fa531

Browse files
mnoconkonradoboza
andauthored
Discounts 4.6.22 (#2810)
* Adjusted code samples * [Discounts] Added doc for 4.6.22 * Fixed limit mention * Added update mention * Removed mentions of OverridePrioritatization * Wording * Update code_samples/discounts/src/Command/ManageDiscountsCommand.php Co-authored-by: Konrad Oboza <[email protected]> * Fixed highlights * Review suggestions * Added missing v prefix --------- Co-authored-by: Konrad Oboza <[email protected]>
1 parent c64cff4 commit 17fa531

File tree

8 files changed

+99
-13
lines changed

8 files changed

+99
-13
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type: discount_code
2+
mode: create
3+
code: summer10
4+
global_usage_limit: 100 # Optional
5+
user_usage_limit: 5 # Optional
6+
created_at: '2023-01-01T12:00:00+00:00' # Optional
7+
creator_id: 42 # Optional

code_samples/discounts/src/Command/ManageDiscountsCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5959

6060
$discountCodeCreateStruct = new DiscountCodeCreateStruct(
6161
'summer10',
62-
null, // Unlimited usage
62+
10, // Global usage limit
63+
null, // Unlimited usage per customer
6364
$this->permissionResolver->getCurrentUserReference()->getUserId(),
6465
$now
6566
);
@@ -78,7 +79,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7879
new IsInRegions(['germany', 'france']),
7980
new IsProductInArray(['product-1', 'product-2']),
8081
new IsInCurrency('EUR'),
81-
new IsValidDiscountCode($discountCode->getCode(), $discountCode->getUsedLimit()),
82+
new IsValidDiscountCode(
83+
$discountCode->getCode(),
84+
$discountCode->getGlobalLimit(),
85+
$discountCode->getUsedLimit()
86+
),
8287
])
8388
->setTranslations([
8489
new DiscountTranslationStruct('eng-GB', 'Discount name', 'This is a discount description', 'Promotion Label', 'Promotion Description'),

docs/api/event_reference/discounts_events.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ The events below are dispatched when managing [discounts](discounts_guide.md):
1515

1616
| Event | Dispatched by |
1717
|---|---|
18-
|[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)
19-
|[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)
20-
|[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)
21-
|[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)
18+
|[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) |
19+
|[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) |
20+
|[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) |
21+
|[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) |
2222
|[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)|
23-
|[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)|
23+
|[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) |
2424

2525
## Form events
2626

docs/content_management/data_migration/importing_data.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ The following data migration step modes are available:
5656
| `currency` | &#10004; | &#10004; | &#10004; | |
5757
| `customer_group` | &#10004; | &#10004; | &#10004; | |
5858
| `discount` | &#10004; | &#10004; | | |
59+
| `discount_code` | &#10004; | | | |
5960
| `language` | &#10004; | | | |
6061
| `location` | | &#10004; | | &#10004; |
6162
| `object_state` | &#10004; | | | |
@@ -531,6 +532,14 @@ The provided conditions overwrite any already existing ones.
531532

532533
For a list of available conditions, see [Discounts API](discounts_api.md#conditions).
533534

535+
### Discount codes [[% include 'snippets/lts-update_badge.md' %]]
536+
537+
You can create a discount code as in the following example:
538+
539+
``` yaml
540+
[[= include_file('code_samples/data_migration/examples/discounts/discount_code_create.yaml') =]]
541+
```
542+
534543
## Criteria
535544

536545
When using `update` or `delete` modes, you can use criteria to identify the objects to operate on.

docs/discounts/discounts_api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ The example below contains a Command creating a cart discount. The discount:
113113
- [depends](#conditions) on
114114
- being bought from Germany or France
115115
- 2 products
116-
- a `summer10` [discount code](#discount-codes) which can be used unlimited number of times
116+
- a `summer10` [discount code](#discount-codes) which can be used only 10 times, but a single customer can use the code multiple times
117117

118-
``` php hl_lines="60-66 68-92"
118+
``` php hl_lines="60-67 69-97"
119119
[[= include_file('code_samples/discounts/src/Command/ManageDiscountsCommand.php') =]]
120120
```
121121

docs/discounts/discounts_guide.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ A shopping cart can have multiple active discounts, but a specific product can o
5959

6060
When two or more discounts can be applied to a single product, the system evaluates the following properties to choose the right one:
6161

62+
- discount code existence (discounts with discount codes have priority over the others)
6263
- discount activation place (cart discounts rank higher over catalog discounts)
6364
- discount priority (higher priority ranks higher)
6465
- discount creation date (newer discounts rank higher)
@@ -107,7 +108,8 @@ These conditions can include:
107108

108109
For **cart discounts**, you can specify an additional text value that needs to be entered in the cart for the discount to apply.
109110

110-
The discount code usage can be limited per customer:
111+
The discount code usage can be limited globally, for example by making the discount valid only for the first 10 customers before it expires.
112+
You can also limit the usage per customer:
111113

112114
- single use: every customer can use this code only once
113115
- limited use: every customer can use the code a specified number of times

docs/release_notes/ibexa_dxp_v4.6.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,43 @@ month_change: true
1010

1111
<div class="release-notes" markdown="1">
1212

13+
[[% set version = 'v4.6.22' %]]
14+
[[= release_note_entry_begin("Discounts " + version, 'TODO', ['LTS Update', 'Commerce']) =]]
15+
16+
#### Global discount codes limits
17+
18+
- You can now [limit the number of times](discounts_guide.md#discount-codes) a discount code can be used before it expires. The discounts created before this release are set to unlimited global usage
19+
20+
#### Discount codes prioritization
21+
22+
- Discounts with discount codes now have priority over the other discounts
23+
24+
#### Discount codes migrations
25+
26+
- You can now create discount codes using [data migrations](importing_data.md#discount-codes).
27+
28+
#### PHP API
29+
30+
The PHP API has been enhanced with the following new classes:
31+
32+
- TODO
33+
34+
[[= release_note_entry_end() =]]
35+
[[= release_note_entry_begin("Ibexa DXP " + version, 'TODO', ['Headless', 'Experience', 'Commerce']) =]]
36+
37+
#### TODO
38+
39+
#### PHP API
40+
41+
The PHP API has been enhanced with the following new classes:
42+
43+
- TODO
44+
45+
#### Full changelog
46+
47+
[[% include 'snippets/release_46.md' %]]
48+
[[= release_note_entry_end() =]]
49+
1350
[[% set version = 'v4.6.21' %]]
1451

1552
[[= release_note_entry_begin("Discounts " + version, '2025-06-11', ['LTS Update', 'Commerce']) =]]

docs/update_and_migration/from_4.6/update_from_4.6.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ Run the following scripts:
376376
psql <database_name> < vendor/ibexa/installer/upgrade/db/postgresql/ibexa-4.6.20-to-4.6.21.sql
377377
```
378378

379+
## v4.6.22
380+
381+
No additional steps needed.
382+
379383
[[% include 'snippets/update/notify_support.md' %]]
380384

381385
With the product updated to the latest version, you can now finish the update process or proceed to updating the LTS Updates packages.
@@ -395,16 +399,16 @@ To use the [latest features](ibexa_dxp_v4.6.md) added to them, update them separ
395399

396400
Then apply manually the changes described below.
397401

398-
## 4.6.20
402+
### Discounts v4.6.20
399403

400-
### Policy changes
404+
#### Policy changes
401405

402406
The `discount/view` policy is no longer required for the store customers to use a discount and must be removed from all users who are not managing discounts.
403407
The policy allows to access all the discount details, including the coupon codes to activate them, which could lead to system abuse.
404408

405409
To learn more, see the [discounts policies overview](policies.md#discounts).
406410

407-
### Database update
411+
#### Database update
408412

409413
Run the following scripts:
410414

@@ -526,6 +530,28 @@ To use the [latest features](ibexa_dxp_v4.6.md) added to them, update them separ
526530
REFERENCES ezuser (contentobject_id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
527531
```
528532

533+
### Discounts v4.6.22
534+
535+
#### Database update
536+
537+
Run the following scripts:
538+
539+
=== "MySQL"
540+
541+
``` sql
542+
ALTER TABLE ibexa_discount ADD override_prioritization tinyint(1) NOT NULL DEFAULT 0;
543+
CREATE INDEX ibexa_discount_prioritization_idx ON ibexa_discount (override_prioritization, type, priority);
544+
ALTER TABLE ibexa_discount_code ADD global_limit INT DEFAULT NULL;
545+
```
546+
547+
=== "PostgreSQL"
548+
549+
``` sql
550+
ALTER TABLE ibexa_discount ADD override_prioritization tinyint(1) NOT NULL DEFAULT 0;
551+
CREATE INDEX ibexa_discount_prioritization_idx ON ibexa_discount (override_prioritization, type, priority);
552+
ALTER TABLE ibexa_discount_code ADD global_limit INT DEFAULT NULL;
553+
```
554+
529555
=== "AI actions"
530556

531557
Run the following command to get the latest version:

0 commit comments

Comments
 (0)