Skip to content

[Discounts] Release notes #2785

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 25 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
38 changes: 38 additions & 0 deletions docs/release_notes/ibexa_dxp_v4.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@
<div class="release-notes" markdown="1">

[[% set version = 'v4.6.20' %]]
[[= release_note_entry_begin("Discounts " + version, '2025-05-28', ['Commerce', 'LTS Update']) =]]

#### Features

- With the introduction of discount code usage limits, you can now limit the number of times a customer can use a discount code before it becomes invalid
- You can now provide your own form themes for the discounts form by using the extension point in [`ibexa_discounts_form_themes` Twig function](discounts_twig_functions.md#ibexa_discounts_form_themes)

#### PHP API

The PHP API has been enhanced with the following new classes:

- [`Ibexa\Contracts\Discounts\Admin\Form\DiscountValueFormTypeMapperInterface`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-DiscountValueFormTypeMapperInterface.html)
- [`Ibexa\Contracts\Discounts\Admin\Form\FormThemeProviderInterface`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-FormThemeProviderInterface.html)
- [`Ibexa\Contracts\DiscountsCodes\Exception\DiscountCodeUnusableException`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Exception-DiscountCodeUnusableException.html)
- [`Ibexa\Contracts\DiscountsCodes\Exception\DiscountCodeUserInvalidArgumentException`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Exception-DiscountCodeUserInvalidArgumentException.html)
- [`Ibexa\Contracts\DiscountsCodes\Value\DiscountCodeUsageInterface`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Value-DiscountCodeUsageInterface.html)
- [`Ibexa\Contracts\DiscountsCodes\Value\DiscountCodeUser`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Value-DiscountCodeUser.html)
- [`Ibexa\Contracts\DiscountsCodes\Value\Query\DiscountCodeUsageQuery`](https://doc.ibexa.co/en/latest/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Value-Query-DiscountCodeUsageQuery.html )

To update to the latest version, see the [update instructions](update_from_4.6.md#lts-updates).

[[= release_note_entry_end() =]]

[[= release_note_entry_begin("Ibexa DXP " + version, '2025-05-27', ['Headless', 'Experience', 'Commerce']) =]]

#### Twig Components
Expand Down Expand Up @@ -44,6 +67,21 @@
[[= release_note_entry_end() =]]

[[% set version = 'v4.6.19' %]]

[[= release_note_entry_begin("Discounts", '2025-04-09', ['Commerce', 'LTS Update', 'New feature']) =]]

With the Discounts LTS Update, you can temporarily or permanently reduce prices on specific products or categories, making deals more attractive to potential buyers.

Use them to encourage first-time purchases, reward loyal customers, promote new or slow-moving items, or drive sales during seasonal events.

Check warning on line 75 in docs/release_notes/ibexa_dxp_v4.6.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/release_notes/ibexa_dxp_v4.6.md#L75

[Ibexa.OxfordComma] Use a comma before the last 'and' or 'or' in a list of four or more items.
Raw output
{"message": "[Ibexa.OxfordComma] Use a comma before the last 'and' or 'or' in a list of four or more items.", "location": {"path": "docs/release_notes/ibexa_dxp_v4.6.md", "range": {"start": {"line": 75, "column": 1}}}, "severity": "WARNING"}

By displaying discounted prices clearly in the catalog or cart, businesses can create a sense of urgency, increase customer satisfaction, and ultimately boost revenue.

![Discounts for products in the cart](4.6_discounts.png)

For more information, see [Discounts product guide](discounts_guide.md).

[[= release_note_entry_end() =]]

[[= release_note_entry_begin("AI Actions " + version, '2025-04-09', ['LTS Update', 'New feature']) =]]

#### Features
Expand Down
Binary file added docs/release_notes/img/4.6_discounts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
description: AI Actions functions allows you to embed AI Actions in your templates
page_type: reference
month_change: false
edition: lts-update
---

# AI Actions Twig functions
Expand Down
101 changes: 101 additions & 0 deletions docs/templating/twig_function_reference/discounts_twig_functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
description: Discounts Twig Functions allow you to operate on discounts in your templates.
page_type: reference
month_change: true
editions:
- lts-update
- commerce
---

# Discounts Twig functions

Discounts Twig Functions allow you to operate on discounts in your templates.

## Filters

### `ibexa_render_discount_rule_type`

This filter transforms the discount type (`fixed_amount` or `percentage`) into a human-friendly and translated label.

``` html+twig
{% set rule_type = discount.getRule().getType() %}

<span class="ibexa-icon-tag">
<svg class="ibexa-icon ibexa-icon--small">
<use xlink:href="{{ ibexa_icon_path('discount-coupon') }}"></use>
</svg>
{{ rule_type|ibexa_render_discount_rule_type }}
</span>
```

## Functions

### `ibexa_discounts_render_discount_badge()`

Use the `ibexa_discounts_render_discount_badge` to render a badge indicating the discounted amount, for example on product cards.

``` html+twig
{% if ibexa_storefront_are_discounts_enabled() %}
{% block product_discount_price_info %}
<div class="ibexa-store-product__discount-price-info">
{% include '@ibexadesign/storefront/component/discount/discount_price.html.twig' with {
original_price: original_price,
} %}
{% embed '@ibexadesign/storefront/component/discount/discount_badge.html.twig' with {
size: 'small',
} %}
{% block content %}
{{- ibexa_discounts_render_discount_badge(discount, price_money) -}}
{% endblock %}
{% endembed %}
</div>
{% endblock %}
{% endif %}
```

### `ibexa_get_original_price()`

Displays the product price before the discount was applied.

``` html+twig
{{ ibexa_get_original_price(product)|ibexa_format_price ?: '-' }}
```

### `ibexa_format_discount_value()`

Formats the discount value for each discount type, for example by displaying `-10 EUR` or `-10%`.

``` html+twig
content: ibexa_format_discount_value(discount),
```

### `ibexa_discounts_is_active()`

Helper function returning whether the discount is currently active.
``` html+twig
{% if ibexa_discounts_is_active(discount) %}
<div>The discount is active</div>
{% endif %}
```

### `ibexa_discounts_form_themes()`

The `ibexa_discounts_form_themes` function serves as an extension point to provide new [form themes]([[= symfony_doc =]]/form/form_themes.html) for the discount form.

To add new ones, create a class implementing the [FormThemeProviderInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-FormThemeProviderInterface.html) interface and provide them in the `getFormThemes` method.

### `ibexa_discounts_can_edit()`

Helper function returning whether the current user has permissions to edit discounts.

### `ibexa_discounts_can_enable()`

Helper function returning whether the current user has permissions to enable discounts.

### `ibexa_discounts_can_disable()`

Helper function returning whether the current user has permissions to disable discounts.

### `ibexa_discounts_can_delete()`

Helper function returning whether the current user has permissions to delete discounts.
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,16 @@ You can use this, for example, to [parametrize the display of products by using

``` html+twig
{{ ibexa_get_anonymous_user_id() }}
```
```

### `ibexa_storefront_are_discounts_enabled()`

This function detects if the [Discounts LTS Update](discounts_guide.md) is installed.

``` html+twig
{% if ibexa_storefront_are_discounts_enabled() %}
<div class="ibexa-store-maincart-item__subtotal-original-price-net ibexa-store-discount-price">
{{- product_price_original_subtotal -}}
</div>
{% endif %}
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ In addition to the [native functions provided by Twig](https://twig.symfony.com/
"templating/twig_function_reference/url_twig_functions",
"templating/twig_function_reference/date_twig_filters",
"templating/twig_function_reference/ai_actions_twig_functions",
"templating/twig_function_reference/discounts_twig_functions",
], columns=4) =]]
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ nav:
- URL Twig functions: templating/twig_function_reference/url_twig_functions.md
- User Twig functions: templating/twig_function_reference/user_twig_functions.md
- AI Twig functions: templating/twig_function_reference/ai_actions_twig_functions.md
- Discounts functions: templating/twig_function_reference/discounts_twig_functions.md
- Twig Components: templating/components.md
- URLs and routes:
- URLs and routes: templating/urls_and_routes/urls_and_routes.md
Expand Down