Skip to content

[Discounts] Configuration #2781

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

Open
wants to merge 4 commits into
base: discounts-rest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 57 additions & 0 deletions docs/discounts/configure_discounts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---

Check warning on line 1 in docs/discounts/configure_discounts.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/discounts/configure_discounts.md#L1

[Ibexa.ReadingLevel] The grade level is 11.54. Aim for 8th grade or lower by using shorter sentences and words.
Raw output
{"message": "[Ibexa.ReadingLevel] The grade level is 11.54. Aim for 8th grade or lower by using shorter sentences and words.", "location": {"path": "docs/discounts/configure_discounts.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}
description: Install the Discounts LTS update.
month_change: true
editions:
- lts-update
- commerce
---

# Discounts configuration

You can customize the behavior of the Discounts feature by using the following [configuration](configuration.md):

## Back Office pagination

Use the built-in SiteAccess-aware parameters to change the default pagination settings.

The following parameters are available:

- `list_per_page_limit` controls the number of discounts displayed on a single page in discount list view
- `products_list_per_page_limit` controls the number of products displayed on a single page in a discount details view

You can set them as in the following example:

``` yaml
ibexa:
system:
admin_group:
discounts:
pagination:
list_per_page_limit: 10
products_list_per_page_limit: 15
```

## Rate limiting

To prevent malicious actors from trying all the possible discount code combinations using brute-force attacks, the [`/discounts_codes/{cartIdentifier}/apply` endpoint](/api/rest_api/rest_api_reference/rest_api_reference.html#discount-codes-apply-discount-to-cart) is rate limited using the [Rate Limiter Symfony component]([[= symfony_doc =]]/rate_limiter.html).

You can adjust the default configuration by modifying the `config/packages/ibexa_discounts_codes.yaml` file created during installation process.

The limiter uses the following pattern: `user_%d_ip_%s`, using Customer ID and Customer IP address to track usage of both logged-in and anonymous customers.
To cover additional use cases, you can add your own logic by listening to the [`BeforeDiscountCodeApplyEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Event-BeforeDiscountCodeApplyEvent.html) event.

Check failure on line 41 in docs/discounts/configure_discounts.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/discounts/configure_discounts.md#L41

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/discounts/configure_discounts.md", "range": {"start": {"line": 41, "column": 151}}}, "severity": "ERROR"}

## Checkout error-handling

A discount can be valid when customer enters the cart, but later become invalid before the checkout process is completed.

For example, this event could occur if the discount expired, was modified, disabled, or deleted before the customer completed the checkout process.

To prevent customers from placing such orders, the Discounts feature comes with built-in error-handling.
Once it detects that a discount that can no longer be used is applied to a product, it stops the checkout process and informs the customer.

This error handling is provided by two event subscribers:

- `Ibexa\Bundle\Checkout\EventSubscriber\DiscountsHaveChangedExceptionSubscriber`
- `Ibexa\Bundle\DiscountsCodes\EventSubscriber\DiscountCodeUnusableExceptionSubscriber`

You can disable this behavior by setting the `ibexa_checkout.error_handlers.enabled` container parameter to `false`, which allows you to provide your own solution for these cases.
5 changes: 3 additions & 2 deletions docs/discounts/discounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ You can also extend the feature, for example, by creating custom pricing rules,

[[= cards([
"discounts/discounts_guide",
"discounts/install_discounts"
], columns=4) =]]
"discounts/install_discounts",
"discounts/configure_discounts"
], columns=3) =]]
25 changes: 2 additions & 23 deletions docs/discounts/install_discounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Install Discounts

Discounts are available as an LTS update to [[= product_name_com =]], starting with version v4.6.19 or higher.
Discounts are available as an LTS update to [[[= product_name_com =]]](/ibexa_products/ibexa_commerce.md), starting with version v4.6.19 or higher.

Check failure on line 11 in docs/discounts/install_discounts.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/discounts/install_discounts.md#L11

[Ibexa.VariablesVersion] Use global variable '[[= latest_tag_4_6 =]]' instead of 'v4.6.19'
Raw output
{"message": "[Ibexa.VariablesVersion] Use global variable '[[= latest_tag_4_6 =]]' instead of 'v4.6.19'", "location": {"path": "docs/discounts/install_discounts.md", "range": {"start": {"line": 11, "column": 130}}}, "severity": "ERROR"}
To use this feature you must first install the packages and configure them.

## Install packages
Expand Down Expand Up @@ -43,25 +43,4 @@

This command modifies the existing database schema by adding database configuration required for using Discounts.

### Configuration (optional)

Use the built-in SiteAccess-aware parameters to change the default discount configuration.

The following settings are available:

- `list_per_page_limit` controls the number of discounts displayed on a single page in discount list view
- `products_list_per_page_limit` controls the number of products displayed on a single page in a discount details view

You can set them as in the following example:

``` yaml
ibexa:
system:
admin_group:
discounts:
pagination:
list_per_page_limit: 10
products_list_per_page_limit: 15
```

You can now restart you application and start working with the Discounts feature.
You can now review the existing [configuration options](configure_discounts.md) to adjust this feature, or restart your application to start working with it.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ nav:
- Discounts: discounts/discounts.md
- Discounts guide: discounts/discounts_guide.md
- Install Discounts: discounts/install_discounts.md
- Configure Discounts: discounts/configure_discounts.md
- Customer management:
- Customer Portal: customer_management/customer_portal.md
- Customer Portal guide: customer_management/customer_portal_guide.md
Expand Down