{% sw_extends '@Storefront/storefront/component/product/card/badges.html.twig' %}
{% block component_product_badges_discount %}
{% if product.extensions.acrisProductBadges is null or product.extensions.acrisProductBadges.elements|length == 0 %}
{% set price = product.calculatedPrice %}
{% if product.calculatedPrices.count > 0 %}
{% set price = product.calculatedPrices.last %}
{% endif %}
{% set listPrice = price.listPrice.percentage > 0 %}
{% set hasRange = product.calculatedPrices.count > 1 %}
{% set displayParent = product.variantListingConfig.displayParent and product.parentId === null %}
{% if displayParent %}
{% set displayFromVariants = displayParent and price.unitPrice !== product.calculatedCheapestPrice.unitPrice %}
{% endif %}
{% set cheapest = product.calculatedCheapestPrice %}
{% set cheapestListPrice = cheapest.listPrice.percentage > 0 %}
{% if (listPrice and not displayFromVariants) or (cheapestListPrice and displayFromVariants) %}
{% if not listPrice or hasRange or displayFromVariants %}
<div class="badge badge-danger badge-discount">
<span>%</span>
</div>
{% endif %}
{{ parent() }}
{% else %}
{{ parent() }}
{% endif %}
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}