{% sw_extends '@Storefront/storefront/page/product-detail/buy-widget-form.html.twig' %}
{# @fourtwosix-edit: FV: Import eveything because changes to form.data-add-to-cart, form.action and csfr.token were needed #}
{% block page_product_detail_buy_form_inner %}
{# @var page \Shopware\Storefront\Page\Product\ProductPage #}
{# @var product \Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity #}
{% set product = page.product %}
{# @fourtwosix-edit: FV: imported custom fields value #}
{% set showPrice = page.product.translated.customFields['akeneo_statusinshoppreiszeigen'] ?? true %}
{% set canBeOrdered = page.product.translated.customFields['akeneo_statusinshopbestellbar'] ?? true %}
{# @fourtwosix-edit: FV: endpoint changed #}
{% if canBeOrdered %}
{% set action = path('frontend.checkout.line-item.add') %}
{% else %}
{% set action = path('fourtwosix.product.request.quotation') %}
{% endif %}
<form
id="productDetailPageBuyProductForm"
action="{{ action }}"
method="post"
class="buy-widget"
{{ canBeOrdered ? 'data-add-to-cart="true"' : '' }}
>
{# @deprecated tag:v6.5.0 - Block page_product_detail_buy_form_inner_csrf will be removed. #}
{% block page_product_detail_buy_form_inner_csrf %}
{% if canBeOrdered %}
{{ sw_csrf('frontend.checkout.line-item.add') }}
{% else %}
{{ sw_csrf('fourtwosix.product.request.quotation') }}
{% endif %}
{% endblock %}
{% set buyable = product.available and product.childCount <= 0 and product.calculatedMaxPurchase > 0 %}
{% block page_product_detail_buy_container %}
{# @fourtwosix-edit: FV: copied also here because of block(page_product_detail_buy_container) used by zenit #}
{% set showPrice = page.product.translated.customFields['akeneo_statusinshoppreiszeigen'] ?? true %}
{% set canBeOrdered = page.product.translated.customFields['akeneo_statusinshopbestellbar'] ?? true %}
{# @fourtwosix-edit: if enableUnitConversion is true we use code copied from fourtwosixBuyByQmUnit otherwise from fourtwosixAddPurchaseUnit #}
{% set productUnitAkeneoKey = product.unit.customFields["akeneo_key"] %}
{% set productPurchaseUnit = product.purchaseUnit %}
{% set enableUnitConversion = productUnitAkeneoKey !== "set" and productUnitAkeneoKey !== "box" and productPurchaseUnit !== 1.0 %}
{% if buyable %}
<div class="buy-widget-container
{% if page.product.unit.translated.name != null and enableUnitConversion %}fourtwosix-qm-unit{% else %}{{ formRowClass }}{% endif %}"
{% if page.product.purchaseUnit != null and enableUnitConversion %} data-buybyqmunit-plugin="true" {% endif %}>
{% block page_product_detail_buy_quantity_container %}
{% if enableUnitConversion %}
{% if page.product.unit.translated.name != null %}
{% sw_include '@Storefront/storefront/component/product/card/price-qm-unit.html.twig' with {
'isCloseout': page.product.isCloseout,
'stock': page.product.calculatedMaxPurchase,
'priceUnit': page.product.calculatedPrice.unitPrice,
'quantityUnit': product.purchaseUnit,
'quantityPack': product.minPurchase,
'sellingUnit': product.minPurchase * product.purchaseUnit,
'purchaseSteps': page.product.purchaseSteps,
'sellingStep': page.product.purchaseSteps * product.purchaseUnit,
'packUnit': product.minPurchase,
'quantityInputName': "lineItems[" ~ page.product.id ~ "][quantity]",
'translatedUnitName': page.product.unit.translated.name,
'minPurchase': product.minPurchase
} %}
{% else %}
{{block("page_product_detail_buy_quantity_container", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
{% endif %}
{% else %}
<div class="col-12 col-md-4 mb-2">
{% set selectQuantityThreshold = 100 %}
{% block page_product_detail_buy_quantity %}
<div class="fourtwosix-add-unit">
{% if (product.calculatedMaxPurchase - product.minPurchase) / product.purchaseSteps > selectQuantityThreshold %}
{% block page_product_detail_buy_quantity_input_group %}
<div class="input-group">
{% block page_product_detail_buy_quantity_input %}
<div class="d-flex">
{{block("page_product_detail_buy_quantity_input", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
{% if page.product.unit != null %}
<input class="form-control w-25" type="text" placeholder="{{page.product.unit.name}}" readonly>
{% endif %}
</div>
{% endblock %}
{% block page_product_detail_buy_quantity_input_unit %}
{{block("page_product_detail_buy_quantity_input_unit", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
{% endblock %}
</div>
{% endblock %}
{% else %}
{% block page_product_detail_buy_quantity_select %}
<div class="d-flex">
{{block("page_product_detail_buy_quantity_select", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
{% if page.product.unit != null %}
<input class="form-control w-25" type="text" placeholder="{{page.product.unit.shortCode}}" readonly>
{% endif %}
</div>
{% endblock %}
{% endif %}
</div>
{% endblock %}
</div>
{% endif %}
{% endblock %}
{% block page_product_detail_buy_redirect_input %}
{# fallback redirect back to detail page is deactivated via js #}
{{block("page_product_detail_buy_redirect_input", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
{% endblock %}
{% block page_product_detail_buy_product_buy_info %}
{{block("page_product_detail_buy_product_buy_info", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
{% endblock %}
{% block page_product_detail_buy_button_container %}
{# @fourtwosix-edit: FV: added check if can be ordered #}
{% if canBeOrdered %}
{% if enableUnitConversion %}
{% if page.product.unit.translated.name != null && page.product.purchaseUnit != null %}
<div class="row mt-4 align-items-center">
<div class="col-12 col-md-6">
{{ "fourtwosix-qm.totalLabel"|trans}}
{# @fourtwosix-edit: FV: manipulate if price is shown #}
{% if showPrice %}
<b class="totalPrice">{{page.product.calculatedPrice.unitPrice|currency(page.product.price|first.currency.currencyId)}}</b>
{% endif %}
</div>
<div class="col-12 col-md-6">
<button class="btn btn-primary btn-block btn-buy" title="{{ "detail.addProduct"|trans|striptags }}" aria-label="{{ "detail.addProduct"|trans|striptags }}">
{{ "detail.addProduct"|trans|sw_sanitize }}
</button>
</div>
</div>
{% else %}
{{block("page_product_detail_buy_button_container", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
{% endif %}
{% else %}
<div class="col-12 col-md-8">
{% block page_product_detail_buy_button %}
{{block("page_product_detail_buy_button", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
{% endblock %}
</div>
{% endif %}
{% else %}
{# @fourtwosix-edit: FV: Reuest quotation form #}
<div class="form-row mt-4">
<div class="form-group col-md-6">
<label for="requestQuotationNameSurname"> {{ 'fourtwosix.request.product.form.nameAndSurname'|trans|sw_sanitize }}</label>
<input required="required" type="text" class="form-control"
name="requestQuotationNameSurname" id="requestQuotationNameSurname">
</div>
<div class="form-group col-md-6">
<label for="requestQuotationEmail"> {{ 'fourtwosix.request.product.form.email'|trans|sw_sanitize }}</label>
<input required="required" type="email" class="form-control"
value="{{ context.customer.email }}" name="requestQuotationEmail"
id="requestQuotationEmail">
</div>
<div class="form-group col-md-4">
<label for="requestQuotationZipcode"> {{ 'fourtwosix.request.product.form.zipcode'|trans|sw_sanitize }}</label>
<input required="required" type="text" class="form-control"
name="requestQuotationZipcode" id="requestQuotationZipcode">
</div>
<div class="form-group col-md-8">
{% set countries = page.countries ? page.countries : page.extensions["FourtwosixShippingCostsCalculator"]["countries"].elements %}
<label for="requestQuotationCountry"> {{ 'fourtwosix.request.product.form.country'|trans|sw_sanitize }}</label>
<select class="form-select form-control" type="text" id="requestQuotationCountry"
name="requestQuotationCountry">
{% for country in countries %}
<option value="{{ country.translated.name }}"
{{ country.id == context.shippingLocation.country.id ? 'selected="selected"' : '' }}>
{{ country.translated.name }}
</option>
{% endfor %}
</select>
</div>
<div class="form-group col-12">
<label for="requestQuotationMessage"> {{ 'fourtwosix.request.product.form.message'|trans|sw_sanitize }}</label>
<textarea required="required" class="form-control" id="requestQuotationMessage" name="requestQuotationMessage"
rows="5"></textarea>
</div>
</div>
{# @fourtwosix-edit: FV hidden inputs #}
<input required="required" type="hidden" name="requestQuotationProductNumber" value="{{ product.productNumber }}"/>
<input required="required" type="hidden" name="requestQuotationProductUnit" value="{{ product.unit.translated.name }}"/>
<input required="required" type="hidden" name="requestQuotationProducId" value="{{ product.id }}"/>
<div class="row mt-4 align-items-center w-100">
<div class="col-12 col-md-6">
{# @fourtwosix-edit: FV: manipulate if price is shown #}
{% if showPrice %}
{{ "fourtwosix-qm.totalLabel"|trans }}
<b class="totalPrice">{{ page.product.calculatedPrice.unitPrice|currency(page.product.price|first.currency.currencyId) }}</b>
{% endif %}
</div>
<div class="col-12 col-md-6">
<input class="btn btn-primary btn-block btn-buy"
type="submit"
value="{{ 'fourtwosix.request.product.price'|trans|striptags }}"
title="{{ 'fourtwosix.request.product.price'|trans|striptags }}"
aria-label="{{ 'fourtwosix.request.product.price'|trans|striptags }}"/>
</div>
</div>
{% endif %}
{% endblock %}
</div>
{% endif %}
{% endblock %}
</form>
{% endblock %}