{% sw_extends '@Storefront/storefront/component/product/card/price-unit.html.twig' %}
{% block component_product_box_price %}
{% set variants = getVariants(product.parentId, context.context) %}
{# {% if not variants %}
single product<br>
{{dump(product.cheapestPrice.price|first.net|currency)}}
{% else %}
variant<br>
{% set parent = getProduct(variants|first.parentId, context.context) %}
{% set price = parent.entities %}
{{dump(price)}}
{% endif %} #}
{% if context.currentCustomerGroup.id != "cfbd5018d38d41d8adca10d94fc8bdd6" %}
<div class="product-price-wrapper">
{# Set the price and conditions for list and regulation prices #}
{% set price = real %}
{% set isListPrice = price.listPrice.percentage > 0 %}
{% set isRegulationPrice = price.regulationPrice is not null %}
<span class="product-price{% if isListPrice and not displayFrom and not displayFromVariants %} with-list-price{% endif %}">
{% if variants %}Ab{% endif %}
{{ price.unitPrice|currency }}
{% if isListPrice and not displayFrom and not displayFromVariants %}
{% set afterListPriceSnippetExists = "listing.afterListPrice"|trans|length > 0 %}
{% set beforeListPriceSnippetExists = "listing.beforeListPrice"|trans|length > 0 %}
{% set hideStrikeThrough = beforeListPriceSnippetExists or afterListPriceSnippetExists %}
<span class="list-price{% if hideStrikeThrough %} list-price-no-line-through{% endif %}">
{% if beforeListPriceSnippetExists %}
{{ "listing.beforeListPrice"|trans|trim|sw_sanitize }}
{% endif %}
{% if afterListPriceSnippetExists %}
{{ "listing.afterListPrice"|trans|trim|sw_sanitize }}
{% endif %}
<span class="list-price-percentage">
{{ "detail.listPricePercentage"|trans({'%price%': price.listPrice.percentage})|sw_sanitize }}
</span>
</span>
{% endif %}
</span>
{% if isRegulationPrice %}
<span class="product-price with-regulation-price">
{% if isListPrice %}<br/>{% endif %}
<span class="regulation-price">
{{ "general.listPricePreviously"|trans({'%price%': price.regulationPrice.price|currency }) }}
</span>
</span>
{% endif %}
</div>
{% endif %}
{# {{dump(product.categoryTree)}} #}
{# Initialize variables #}
{% set categoryTreeToSearch = product.categoryTree %}
{% set targetCategory = "b694a587db9a4145817b22779a409c08" %}
{% set categoryCount = categoryTreeToSearch|length %}
{% set categoryFound = false %}
{# Loop through categoryTreeToSearch to find targetCategory #}
{% for category in categoryTreeToSearch %}
{% if category == targetCategory %}
{% set categoryFound = true %}
{% break %}
{% endif %}
{% endfor %}
{# Debug output to ensure the variables are correct #}
{#
Category Count: {{ categoryCount }}<br>
Category Found: {{ categoryFound ? 'Yes' : 'No' }}<br>
#}
{# {{dump(context.currentCustomerGroup.id)}} #}
{# Final condition to display specific content #}
{# {% if categoryFound and categoryCount < 4 %} #}
{# <p style="color: #e52427; font-weight: 700;">Der Artikel wird gerade eingeführt und kann bald bestellt werden.</p> #}
{% if product %}
{% set variants = getVariants(product.parentId, context.context) %}
{% set totalStock = 0 %}
{% set hasVariants = variants|length > 0 %}
{% for variant in variants %}
{% set stock = variant.availableStock %}
{% if stock < 0 %}
{% set stock = 0 %}
{% endif %}
{# StockVariant: {{ stock }} <br> #}
{% set totalStock = totalStock + stock %}
{% endfor %}
{% if not hasVariants %}
{% set totalStock = totalStock + product.stock %}
{% endif %}
{# <b>Total Stock: {{ totalStock }}</b> #}
<div class="product-available">
{% if context.currentCustomerGroup.id == "cfbd5018d38d41d8adca10d94fc8bdd6" %}
{% if totalStock > 20 %}
<span class="traffic green">
<span class="dot green"></span>
{{ 'available.verfuegbar'|trans }}
</span>
{% elseif totalStock > 0 %}
<span class="traffic yellow">
<span class="dot yellow"></span>
{{ 'available.wenige_verfuegbar'|trans }}
</span>
{% else %}
<span class="traffic red">
<span class="dot red"></span>
{{ 'available.nicht_verfuegbar'|trans }}
</span>
{% endif %}
{% else %}
{% if totalStock > 150 %}
<span class="traffic green">
<span class="dot green"></span>
{{ 'available.mehr_als_150_stueck_verfuegbar'|trans }}
</span>
{% elseif totalStock > 20 %}
<span class="traffic green">
<span class="dot green"></span>
{{ totalStock }} {{ 'available.verfuegbar'|trans }}
</span>
{% elseif totalStock > 0 %}
<span class="traffic yellow">
<span class="dot yellow"></span>
{{ 'available.nurnoch'|trans }} {{ totalStock }} {{ 'available.verfuegbar'|trans }}
</span>
{% else %}
<span class="traffic red">
<span class="dot red"></span>
{{ 'available.nicht'|trans }} {{ 'available.verfuegbar'|trans }}
</span>
{% endif %}
{% endif %}
</div>
<div class="releasedate">
{% if product.releaseDate && totalStock == 0 %}
<span class="dot yellow"></span> Wieder lieferbar ab {{ product.releaseDate|format_date('long', locale=app.request.locale) }}
{% endif %}
</div>
{% endif %}
{% endblock %}
{% block component_product_box_price_unit %}
{% endblock %}