{% sw_extends '@Storefront/storefront/page/product-detail/buy-widget-form.html.twig' %}
{% block page_product_detail_buy_container %}
{{ parent() }}
{% block page_product_detail_buy_container_apple_direct %}
{# this is for Shopware < 6.4 #}
{% set buyableLegacy = (not page.product.isCloseout or (page.product.availableStock >= page.product.minPurchase)) and page.product.childCount <= 0 %}
{# this is for Shopware >= 6.4 #}
{% set buyable = product.available and product.childCount <= 0 and product.calculatedMaxPurchase > 0 %}
{% set productPrice = 0 %}
{% if product.calculatedPrices|length == 1 %}
{% set productPrice = product.calculatedPrices.first.unitPrice %}
{% else %}
{% set productPrice = product.calculatedPrice.unitPrice %}
{% if listPrice.percentage > 0 %}
{% set productPrice = listPrice.price %}
{% endif %}
{% endif %}
{% if mollie_applepaydirect_enabled and ('pdp' not in mollie_applepaydirect_restrictions) and ((buyableLegacy) or (buyable and productPrice) > 0) %}
{% block page_product_detail_buy_container_apple_direct_component %}
<div class="form-row mt-3 justify-content-end js-apple-pay-container">
{% include '@MolliePayments/mollie/component/apple-pay-direct-button.twig' with {cols: 'col-8'} %}
</div>
{% endblock %}
{% endif %}
{% endblock %}
{% endblock %}
{% block page_product_detail_buy_button %}
{% if mollie_subscriptions_enabled and page.product.customFields.mollie_payments_product_subscription_enabled %}
<button class="btn btn-primary btn-block btn-buy" title="{{ "molliePayments.subscriptions.product.addToCartText"|trans|sw_sanitize }}" aria-label="{{ "molliePayments.subscriptions.product.addToCartText"|trans|sw_sanitize }}">
{{ "molliePayments.subscriptions.product.addToCartText"|trans|sw_sanitize }}
</button>
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}