{% sw_extends '@Storefront/storefront/page/product-detail/properties.html.twig' %}
{% set customFields = (page.product.customFields|default({}))|merge(page.product.translated.customFields|default({})) %}
{% set hidePropertiesContainerValue = customFields.itp_hide_properties_container ?? customFields.itp_hide_properties_container_ ?? false %}
{% set hidePropertiesContainerEnabled = hidePropertiesContainerValue in [true, 1, '1', 'true', 'on', 'yes'] %}
{% block page_product_detail_properties_inner %}
{% if not hidePropertiesContainerEnabled %}
<div class="product-detail-properties">
{% block page_product_detail_properties_container %}
<div class="row product-detail-properties-container">
<div class="col-md-12 col-lg-6">
{% block page_product_detail_properties_table %}
<table class="table table-striped product-detail-properties-table">
<tbody>
{% set thread = page.product.sortedProperties.first %}
<tr class="properties-row">
{% block page_product_detail_propertie_thread_item_label %}
<th class="properties-label">{{ thread.translated.name|e }}:</th>
{% endblock %}
{% block page_product_detail_propertie_thread_item_value %}
<td class="properties-value">
{% apply spaceless %}
{% for option in thread.options %}
{% set i = ( i | default(0) ) + 1 %}
<span>{% if i > 1 %}, {% endif %}{{ option.translated.name|e }}</span>
{% endfor %}
{% endapply %}
</td>
{% endblock %}
</tr>
{# Black list for these custom fields to be never displayed #}
{% set blacklist = [
'itp_hide_properties_container',
'itp_hide_properties_container_',
'itp_product_attributes_shop_de',
'itp_product_attributes_shop_us',
'itp_product_attributes_text2_de',
'itp_product_attributes_text2_en',
'itp_product_attributes_order_number',
'itp_product_attributes_chemically_resistant',
'extended_itp_skus',
'show_extended_itp_skus',
'itp_product_attributes_zeiss_no_2',
'itp_product_attributes_certificate',
'custom_cio_tetra_not_discountable'
] %}
{# Allow list for these custom fields to be displayed at the bottom of the list #}
{% set bottomCustomFields = [
'itp_product_attributes_zeiss_no',
'itp_product_attributes_renishaw_no',
'itp_product_attributes_carbide_no',
'itp_product_attributes_qmark_no',
'itp_product_attributes_blum_no',
'itp_product_attributes_hexagon_no',
'itp_product_attributes_mitutoyo_no',
'itp_product_attributes_klingenberg_no',
'itp_product_attributes_heidenhain_no',
'itp_product_attributes_faro_no',
'itp_product_attributes_marpos_no',
'itp_product_attributes_goekler_no'
] %}
{# CIO-AI-Driven: Bool-ähnliche CustomFields explizit als Ja/Nein rendern #}
{% set booleanCustomFields = [
'itp_product_attributes_compatible_with_cnc'
] %}
{% for key, customField in customFields %}
{% set isTruthy = customField in [true, 1, '1', 'true', 'on', 'yes'] %}
{% set showRow = key not in booleanCustomFields or isTruthy %}
{% if customField is not null and key not in blacklist and key not in bottomCustomFields and showRow %}
{% set transName = "customFields." ~ key %}
<tr class="properties-row">
<th class="properties-label">{{ transName|trans|sw_sanitize }}:
</th>
<td class="properties-value">
{% if key in booleanCustomFields %}
{{ "yes"|trans|sw_sanitize }}
{% elseif customField matches '/^\\d+$/' %}
<span>{{ customField|number_format(1, '.', ',') }}</span>
{% else %}
<span>{{ customField }}</span>
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
{% for group in page.product.sortedProperties %}
{% set position = group.translated.position ?? group.position ?? 0 %}
{% if not loop.first and position < 90 %}
<tr class="properties-row">
<th class="properties-label">{{ group.translated.name|e }}:</th>
<td class="properties-value">
{% apply spaceless %}
{% for option in group.options %}
{% set i = ( i | default(0) ) + 1 %}
<span>{% if i > 1 %}, {% endif %}{{ option.translated.name|e }}</span>
{% endfor %}
{% endapply %}
</td>
</tr>
{% endif %}
{% endfor %}
{% if page.product.weight is not null %}
<tr class="properties-row">
{% block page_product_detail_propertie_weight_item_label %}
<th class="properties-label">{{ "component.product.feature.label.weight"|trans }}</th>
{% endblock %}
{% block page_product_detail_propertie_weight_item_value %}
<td class="properties-value"><span>{{ page.product.weight }}</span></td>
{% endblock %}
</tr>
{% endif %}
{# Properties with position >= 90 (displayed after weight) #}
{% for group in page.product.sortedProperties %}
{% set position = group.translated.position ?? group.position ?? 0 %}
{% if position >= 90 %}
<tr class="properties-row">
<th class="properties-label">{{ group.translated.name|e }}:</th>
<td class="properties-value">
{% apply spaceless %}
{% for option in group.options %}
{% set i = ( i | default(0) ) + 1 %}
<span>{% if i > 1 %}, {% endif %}{{ option.translated.name|e }}</span>
{% endfor %}
{% endapply %}
</td>
</tr>
{% endif %}
{% endfor %}
{% for key, customField in customFields %}
{% if customField is not null and key in bottomCustomFields %}
{% set transName = "customFields." ~ key %}
<tr class="properties-row">
<th class="properties-label">{{ transName|trans|sw_sanitize }}:
</th>
<td class="properties-value">
<span>{{ customField }}</span>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% endblock %}
</div>
{% block itp_us_second_product_image %}
{% set images = page.product.media.elements %}
{% if images|length > 1 %}
{% set image = images|slice(1, 1)|first %}
<div class="col-md-12 col-lg-4 text-center">
{% set altAndTitle = "detail.altTitleTagDrawing"|trans ~ page.product.translated.name %}
{% set attributes = {
'class': 'img-fluid product-detail-properties-image',
'alt': altAndTitle,
'title': altAndTitle ,
'data-full-image': image.url
} %}
{% if displayMode == 'cover' or displayMode == 'contain' %}
{% set attributes = attributes|merge({ 'data-object-fit': displayMode }) %}
{% endif %}
{% if isProduct %}
{% set attributes = attributes|merge({ 'itemprop': 'image' }) %}
{% endif %}
{% sw_thumbnails 'gallery-slider-image-thumbnails' with {
media: image.media
} %}
</div>
{% endif %}
{% endblock %}
</div>
{% endblock %}
</div>
{% endif %}
{% endblock %}