| description | page_type | month_change | editions | |
|---|---|---|---|---|
Discounts Twig Functions allow you to operate on discounts in your templates. |
reference |
false |
|
Discounts Twig Functions allow you to operate on discounts in your templates.
This filter transforms the discount type (fixed_amount or percentage) into a human-friendly and translated label.
{% 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-ticket') }}"></use>
</svg>
{{ rule_type|ibexa_render_discount_rule_type }}
</span>
Use the ibexa_discounts_render_discount_badge to render a badge indicating the discounted amount, for example on product cards.
{% 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 %}
Displays the product price before the discount was applied.
{{ ibexa_get_original_price(product)|ibexa_format_price ?: '-' }}
Formats the discount value for each discount type, for example by displaying -10 EUR or -10%.
content: ibexa_format_discount_value(discount),
Helper function returning whether the discount is currently active.
{% if ibexa_discounts_is_active(discount) %}
<div>The discount is active</div>
{% endif %}
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 interface and provide them in the getFormThemes method.
Helper function returning whether the current user has permissions to edit discounts.
Helper function returning whether the current user has permissions to enable discounts.
Helper function returning whether the current user has permissions to disable discounts.
Helper function returning whether the current user has permissions to delete discounts.