{% sw_extends '@Storefront/storefront/component/delivery-information.html.twig' %}
{% block component_delivery_information %}
{# @var product \Shopware\Core\Content\Product\ProductEntity #}
{% if page is defined and page.product is defined %}
{% set product = page.product %}
{% endif %}
<div class="product-delivery-information">
{% if product.shippingFree %}
{% block component_delivery_information_shipping_free %}
{{ parent() }}
{% endblock %}
{% endif %}
{% if not product.active %}
{% block component_delivery_information_not_available %}
{{ parent() }}
{% endblock %}
{% elseif product.releaseDate %}
{% block component_delivery_information_pre_order %}
{% set today = "now"|date('U') %}
{% set isPreorderProduct = product.extensions.preorderData ? true : false %}
{% set preorderDeadlineReached = product.customFields.custom_preorder_deadline|date('U') < today %}
{% set minimalOrderAmountReached = product.customFields.custom_preorder_sales_1 > 0 and product.customFields.custom_preorder_sales_1 <= product.extensions.preorderData.totalOrderAmount %}
{% set releaseDateReached = product.releaseDate|date('U') < today %}
{% set startProductionDateReached = product.customFields.custom_preorder_start_production| date('U') < today %}
{% if not releaseDateReached %}
<link itemprop="availability"
href="http://schema.org/PreOrder"/>
<div class="delivery-information delivery-preorder d-flex">
<div>
<span class="delivery-status-indicator bg-warning"></span>
</div>
<div class="flex-grow-1">
{{ "general.deliveryShipping"|trans|sw_sanitize }} {{ product.releaseDate|format_date('long', locale=app.request.locale) }}
{% if product.customFields.custom_preorder_deadline and isPreorderProduct %}
<br>{{ "wabs-product-preorder.productPage.deadline"|trans }} {{ product.customFields.custom_preorder_deadline|format_date('long', locale=app.request.locale) }}
{% endif %}
</div>
</div>
{% endif %}
{% if isPreorderProduct %}
<div class="preorder-phase-info">
{% if not preorderDeadlineReached %}
{% if startProductionDateReached %}
{% sw_include '@Storefront/storefront/utilities/alert.html.twig' with
{ type: "info",icon: "false", content: 'wabs-product-preorder.phase.production'|trans } %}
{% else %}
{% sw_include '@Storefront/storefront/utilities/alert.html.twig' with
{ type: "warning",icon: "false", content: 'wabs-product-preorder.phase.order'|trans } %}
{% endif %}
{% endif %}
{% if minimalOrderAmountReached %}
{% if preorderDeadlineReached %}
{% if product.extensions.preorderData.hasWareneingang or releaseDateReached %}
{% sw_include '@Storefront/storefront/utilities/alert.html.twig' with
{ type: "success",icon: "false", content: 'wabs-product-preorder.phase.delivery'|trans } %}
{% else %}
{% sw_include '@Storefront/storefront/utilities/alert.html.twig' with
{ type: "info",icon: "false", content: 'wabs-product-preorder.phase.production'|trans } %}
{% endif %}
{% elseif startProductionDateReached %}
{% sw_include '@Storefront/storefront/utilities/alert.html.twig' with
{ type: "info",icon: "false", content: 'wabs-product-preorder.phase.production'|trans } %}
{% endif %}
{% endif %}
{% if preorderDeadlineReached and not minimalOrderAmountReached %}
{% sw_include '@Storefront/storefront/utilities/alert.html.twig' with
{ type: "danger",icon: "false", content: 'wabs-product-preorder.phase.failed'|trans } %}
{% endif %}
</div>
{% if not releaseDateReached %}
{% if product.customFields.custom_preorder_info %}
<div class="product-detail-preorder-product-infobox-container">
<div class="product-detail-preorder-infobox">
<div>
{{ product.customFields.custom_preorder_info|raw }}
</div>
</div>
</div>
{% endif %}
{% if product.extensions.preorderData.totalOrderAmount is not null %}
<div class="preorder-current-status">
{{ "wabs-product-preorder.productPage.currentStatus"|trans }} {{ product.extensions.preorderData.totalOrderAmount }}
</div>
{% endif %}
{% endif %}
{% endif %}
{% endblock %}
{% elseif product.availableStock >= product.minPurchase and product.deliveryTime %}
{% block component_delivery_information_available %}
{{ parent() }}
{% endblock %}
{% elseif product.isCloseout and product.availableStock < product.minPurchase %}
{% block component_delivery_information_soldout %}
{{ parent() }}
{% endblock %}
{% elseif product.availableStock < product.minPurchase and product.deliveryTime and product.restockTime %}
{% block component_delivery_information_restock %}
{{ parent() }}
{% endblock %}
{% else %}
{% block component_delivery_information_default %}{% endblock %}
{% endif %}
</div>
{% endblock %}