{% sw_extends '@Storefront/storefront/component/product/card/badges.html.twig' %}
{# ThemeWare: Set theme variables #}
{% set twtProductBadgesDiscountBadgeShow = theme_config('twt-product-badges-discount-badge-show') %}
{% set twtProductBadgesDiscountBadgeType = theme_config('twt-product-badges-discount-badge-type') %}
{% set twtProductBadgesNewBadgeShow = theme_config('twt-product-badges-new-badge-show') %}
{% set twtProductBadgesShippingFreeBadgeShow = theme_config('twt-product-badges-shipping-free-badge-show') %}
{% set twtProductBadgesSoldBadgeShow = theme_config('twt-product-badges-sold-badge-show') %}
{% set twtProductBadgesStockBadgeShow = theme_config('twt-product-badges-stock-badge-show') %}
{% set twtProductBadgesTopsellerBadgeShow = theme_config('twt-product-badges-topseller-badge-show') %}
{% set twtProductBadgesDiscountBadgeCompatibility = theme_config('twt-product-badges-discount-badge-compatibility') %}
{% set twtProductBadgesTopsellerBadgeCompatibility = theme_config('twt-product-badges-topseller-badge-compatibility') %}
{% set twtProductBadgesNewBadgeCompatibility = theme_config('twt-product-badges-new-badge-compatibility') %}
{% block component_product_badges_discount %}
{% if twtProductBadgesStockBadgeShow == 2 %}
{% sw_include '@Storefront/storefront/themeware/includes/twt-badge-stock-include.html.twig' ignore missing with {
product: product,
type: 'listing'
} %}
{% endif %}
{% if twtProductBadgesSoldBadgeShow == 2 %}
{% sw_include '@Storefront/storefront/themeware/includes/twt-badge-sold-include.html.twig' ignore missing with {
product: product,
type: 'listing'
} %}
{% endif %}
{% if twtProductBadgesShippingFreeBadgeShow == 2 %}
{% sw_include '@Storefront/storefront/themeware/includes/twt-badge-shipping-free-include.html.twig' ignore missing with {
product: product,
type: 'listing'
} %}
{% endif %}
{% if zeobvVisibleDiscountConfig.showDiscountsOnListingPages
or shopware.config.ZeobvVisibleDiscounts.config.showDiscountsOnListingPages %}
{% set listPrice = product.calculatedPrice.listPrice %}
{% if listPrice.price and listPrice.price < product.calculatedPrice.unitPrice %}
{% set discount = (100 - ((product.calculatedListingPrice.from.unitPrice/listPrice.price) * 100))|round(2, 'floor') %}
{% elseif listPrice.price and product.calculatedPrice.unitPrice %}
{% set discount = (100 - ((product.calculatedPrice.unitPrice/listPrice.price) * 100))|round(2, 'floor') %}
{% endif %}
{% set badgeConfig = product.extension('zeobvVisibleDiscountInfo').badgeConfig %}
{% if zeobvVisibleDiscountConfig.showDiscountBadgeOnListingPages %}
{% if badgeConfig|length > 0 %}
{% for badge in badgeConfig %}
{% set label = badge.label ? badge.label : (discount >= 1 ? discount|round(zeobvVisibleDiscountConfig.percentagePrecision) ~ " %" : false) %}
<div>
<div class="badge badge-danger badge-discount"{% if badge.color %} style="background-color: {{ badge.color }}"{% endif %}>
<span>{{ label }}</span>
</div>
</div>
{% endfor %}
{% elseif discount >= 1 %}
<div class="badge badge-danger badge-discount">
<span>{{ discount|round(zeobvVisibleDiscountConfig.percentagePrecision) }} %</span>
</div>
{% endif %}
{% endif %}
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}