Skip to content

[Discounts] Preview #2772

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

Merged
merged 18 commits into from
Jun 11, 2025
Merged

[Discounts] Preview #2772

merged 18 commits into from
Jun 11, 2025

Conversation

mnocon
Copy link
Contributor

@mnocon mnocon commented Jun 9, 2025

A preview PR for all the things related to discounts.

Made to:

  1. Allow previewing all the discount changes together
  2. Make the merge process of discounts faster

Copy link

github-actions bot commented Jun 9, 2025

Preview of modified files: Too many files modified in a single PR, preview link list is skipped. (165 files &gth; 100)

@mnocon mnocon changed the title Discounts [Discounts] Preview Jun 9, 2025
mnocon and others added 18 commits June 11, 2025 13:02
* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts
* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md
Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column
* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide
* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
* Added update instructions

* Fixed link
Copy link

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/data_migration/examples/discounts/discount_create.yaml


code_samples/data_migration/examples/discounts/discount_create.yaml

docs/content_management/data_migration/importing_data.md@514:``` yaml
docs/content_management/data_migration/importing_data.md@515:[[= include_file('code_samples/data_migration/examples/discounts/discount_create.yaml') =]]
docs/content_management/data_migration/importing_data.md@516:```

001⫶- type: discount
002⫶ mode: create
003⫶ identifier: summer_sale_2025
004⫶ translations:
005⫶ -
006⫶ language_code: eng-GB
007⫶ name: "Summer Sale 2025"
008⫶ description: "-10% on laptops"
009⫶ label: "HOT DEAL: Summer Sale!"
010⫶ label_description: "Get 10% off on selected items!"
011⫶ discount_type: cart
012⫶ priority: 8
013⫶ enabled: true
014⫶ user: admin
015⫶ startDate: '2024-01-01T00:01:00+00:00'
016⫶ endDate: null
017⫶ createdAt: null
018⫶ updatedAt: null
019⫶ rule:
020⫶ type: percentage
021⫶ expressionValues:
022⫶ discount_percentage: 10
023⫶ conditions:
024⫶ -
025⫶ identifier: is_in_currency
026⫶ expressionValues:
027⫶ currency_code: EUR
028⫶ -
029⫶ identifier: is_product_in_array
030⫶ expressionValues:
031⫶ product_codes:
032⫶ - product_code_book_0
033⫶ - product_code_book_1
034⫶ -
035⫶ identifier: is_product_in_quantity_in_cart
036⫶ expressionValues:
037⫶ quantity: 2


code_samples/data_migration/examples/discounts/discount_update.yaml


code_samples/data_migration/examples/discounts/discount_update.yaml

docs/content_management/data_migration/importing_data.md@521:``` yaml
docs/content_management/data_migration/importing_data.md@522:[[= include_file('code_samples/data_migration/examples/discounts/discount_update.yaml') =]]
docs/content_management/data_migration/importing_data.md@523:```

001⫶- type: discount
002⫶ mode: update
003⫶ match:
004⫶ field: identifier
005⫶ value: summer_sale_2025
006⫶ identifier: summer_sale_2025_updated
007⫶ translations:
008⫶ eng-GB:
009⫶ language_code: eng-GB
010⫶ name: Updated name
011⫶ description: Updated description
012⫶ label: Updated promotion label
013⫶ label_description: Updated promotion description
014⫶ priority: 5
015⫶ active: true
016⫶ user: admin
017⫶ startDate: '2024-01-01T00:00:00+00:00'
018⫶ endDate: null
019⫶ createdAt: null
020⫶ updatedAt: null
021⫶ rule:
022⫶ type: percentage
023⫶ expressionValues:
024⫶ discount_percentage: '10'
025⫶ conditions:
026⫶ -
027⫶ identifier: is_product_in_quantity_in_cart
028⫶ expressionValues:
029⫶ quantity: 2


code_samples/discounts/src/Query/Search.php


code_samples/discounts/src/Query/Search.php

docs/search/discounts_search_reference/discounts_criteria.md@32:```php hl_lines="13-20"
docs/search/discounts_search_reference/discounts_criteria.md@33:[[= include_file('code_samples/discounts/src/Query/Search.php') =]]
docs/search/discounts_search_reference/discounts_criteria.md@34:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion;
006⫶use Ibexa\Contracts\Discounts\Value\Query\Criterion;
007⫶use Ibexa\Contracts\Discounts\Value\Query\DiscountQuery;
008⫶use Ibexa\Contracts\Discounts\Value\Query\SortClause;
009⫶
010⫶$now = new DateTimeImmutable();
011⫶
012⫶$query = new DiscountQuery(
013❇️ new Criterion\LogicalAnd(
014❇️ new Criterion\IsEnabledCriterion(),
015❇️ new Criterion\StartDateCriterion($now, FieldValueCriterion::COMPARISON_LTE),
016❇️ new Criterion\LogicalOr(
017❇️ new Criterion\EndDateCriterion($now, FieldValueCriterion::COMPARISON_GTE),
018❇️ new Criterion\EndDateCriterion(null, FieldValueCriterion::COMPARISON_EQ)
019❇️ ),
020❇️ ),
021⫶ [
022⫶ new SortClause\Type(),
023⫶ new SortClause\Priority(),
024⫶ new SortClause\CreatedAt(),
025⫶ ]
026⫶);
027⫶
028⫶/** @var \Ibexa\Contracts\Discounts\DiscountServiceInterface $discountService */
029⫶$results = $discountService->findDiscounts($query);

docs/search/discounts_search_reference/discounts_sort_clauses.md@25:```php hl_lines="22-24"
docs/search/discounts_search_reference/discounts_sort_clauses.md@26:[[= include_file('code_samples/discounts/src/Query/Search.php') =]]
docs/search/discounts_search_reference/discounts_sort_clauses.md@27:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion;
006⫶use Ibexa\Contracts\Discounts\Value\Query\Criterion;
007⫶use Ibexa\Contracts\Discounts\Value\Query\DiscountQuery;
008⫶use Ibexa\Contracts\Discounts\Value\Query\SortClause;
009⫶
010⫶$now = new DateTimeImmutable();
011⫶
012⫶$query = new DiscountQuery(
013⫶ new Criterion\LogicalAnd(
014⫶ new Criterion\IsEnabledCriterion(),
015⫶ new Criterion\StartDateCriterion($now, FieldValueCriterion::COMPARISON_LTE),
016⫶ new Criterion\LogicalOr(
017⫶ new Criterion\EndDateCriterion($now, FieldValueCriterion::COMPARISON_GTE),
018⫶ new Criterion\EndDateCriterion(null, FieldValueCriterion::COMPARISON_EQ)
019⫶ ),
020⫶ ),
021⫶ [
022❇️ new SortClause\Type(),
023❇️ new SortClause\Priority(),
024❇️ new SortClause\CreatedAt(),
025⫶ ]
026⫶);
027⫶
028⫶/** @var \Ibexa\Contracts\Discounts\DiscountServiceInterface $discountService */
029⫶$results = $discountService->findDiscounts($query);

Download colorized diff

@mnocon mnocon marked this pull request as ready for review June 11, 2025 13:50
@mnocon mnocon merged commit 76d181c into 4.6 Jun 11, 2025
5 of 6 checks passed
@mnocon mnocon deleted the discounts branch June 11, 2025 13:51
mnocon added a commit that referenced this pull request Jun 11, 2025
* [PHP API] Discounts (#2763)

* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts

* Discount product guide

* Fixed links and navigation

* Removed nav

* Fixed links

* Fixed typo

* Fixed badges

* Removed whitespace

* Fixes before review

* After review fixes

* Currency remark

* Discount migrations (#2768)

* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md

* Applied suggestions from code review (#2767)

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Search overview (#2773)

* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Event reference (#2776)

* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column

* [Discounts] Mentioned discounts in pricing and customer groups (#2775)

* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide

* [Discounts] Discount policies (#2771)

* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* Discounts update (#2774)

* Added update instructions

* Fixed link

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant