custom/plugins/FourtwosixThemeExtension/src/Resources/views/storefront/page/product-detail/buy-widget-form.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/page/product-detail/buy-widget-form.html.twig' %}
  2. {# @fourtwosix-edit: FV: Import eveything because changes to form.data-add-to-cart, form.action and csfr.token were needed  #}
  3. {% block page_product_detail_buy_form_inner %}
  4.     {# @var page \Shopware\Storefront\Page\Product\ProductPage #}
  5.     {# @var product \Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity #}
  6.     {% set product = page.product %}
  7.     {# @fourtwosix-edit: FV: imported custom fields value #}
  8.     {% set showPrice = page.product.translated.customFields['akeneo_statusinshoppreiszeigen']  ?? true %}
  9.     {% set canBeOrdered = page.product.translated.customFields['akeneo_statusinshopbestellbar'] ?? true %}
  10.     {# @fourtwosix-edit: FV: endpoint changed #}
  11.     {% if canBeOrdered %}
  12.         {% set action = path('frontend.checkout.line-item.add') %}
  13.     {% else %}
  14.         {% set action = path('fourtwosix.product.request.quotation') %}
  15.     {% endif %}
  16.     <form
  17.             id="productDetailPageBuyProductForm"
  18.             action="{{ action }}"
  19.             method="post"
  20.             class="buy-widget"
  21.             {{ canBeOrdered ? 'data-add-to-cart="true"' : '' }}
  22.     >
  23.     {# @deprecated tag:v6.5.0 - Block page_product_detail_buy_form_inner_csrf will be removed. #}
  24.     {% block page_product_detail_buy_form_inner_csrf %}
  25.         {% if canBeOrdered %}
  26.             {{ sw_csrf('frontend.checkout.line-item.add') }}
  27.         {% else %}
  28.             {{ sw_csrf('fourtwosix.product.request.quotation') }}
  29.         {% endif %}
  30.     {% endblock %}
  31.     {% set buyable = product.available and product.childCount <= 0 and product.calculatedMaxPurchase > 0 %}
  32.     {% block page_product_detail_buy_container %}
  33.         {# @fourtwosix-edit: FV: copied also here because of block(page_product_detail_buy_container) used by zenit  #}
  34.         {% set showPrice = page.product.translated.customFields['akeneo_statusinshoppreiszeigen']  ?? true %}
  35.         {% set canBeOrdered = page.product.translated.customFields['akeneo_statusinshopbestellbar'] ?? true %}
  36.         {# @fourtwosix-edit: if enableUnitConversion is true we use code copied from fourtwosixBuyByQmUnit otherwise from fourtwosixAddPurchaseUnit #}
  37.         {% set productUnitAkeneoKey = product.unit.customFields["akeneo_key"] %}
  38.         {% set productPurchaseUnit =  product.purchaseUnit %}
  39.         {% set enableUnitConversion = productUnitAkeneoKey !== "set" and  productUnitAkeneoKey !== "box" and productPurchaseUnit !== 1.0 %}
  40.         {% if buyable %}
  41.             <div class="buy-widget-container
  42.                 {% if page.product.unit.translated.name != null and enableUnitConversion %}fourtwosix-qm-unit{% else %}{{ formRowClass }}{% endif %}"
  43.                     {% if page.product.purchaseUnit != null and enableUnitConversion %} data-buybyqmunit-plugin="true" {% endif %}>
  44.                 {% block page_product_detail_buy_quantity_container %}
  45.                     {% if enableUnitConversion %}
  46.                         {% if page.product.unit.translated.name != null %}
  47.                             {% sw_include '@Storefront/storefront/component/product/card/price-qm-unit.html.twig' with {
  48.                                 'isCloseout': page.product.isCloseout,
  49.                                 'stock': page.product.calculatedMaxPurchase,
  50.                                 'priceUnit': page.product.calculatedPrice.unitPrice,
  51.                                 'quantityUnit': product.purchaseUnit,
  52.                                 'quantityPack': product.minPurchase,
  53.                                 'sellingUnit': product.minPurchase * product.purchaseUnit,
  54.                                 'purchaseSteps': page.product.purchaseSteps,
  55.                                 'sellingStep': page.product.purchaseSteps * product.purchaseUnit,
  56.                                 'packUnit': product.minPurchase,
  57.                                 'quantityInputName': "lineItems[" ~ page.product.id ~ "][quantity]",
  58.                                 'translatedUnitName': page.product.unit.translated.name,
  59.                                 'minPurchase': product.minPurchase
  60.                             } %}
  61.                         {% else %}
  62.                             {{block("page_product_detail_buy_quantity_container", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
  63.                         {% endif %}
  64.                     {% else %}
  65.                         <div class="col-12 col-md-4 mb-2">
  66.                             {% set selectQuantityThreshold = 100 %}
  67.                             {% block page_product_detail_buy_quantity %}
  68.                                 <div class="fourtwosix-add-unit">
  69.                                     {% if (product.calculatedMaxPurchase - product.minPurchase) / product.purchaseSteps > selectQuantityThreshold %}
  70.                                         {% block page_product_detail_buy_quantity_input_group %}
  71.                                             <div class="input-group">
  72.                                                 {% block page_product_detail_buy_quantity_input %}
  73.                                                     <div class="d-flex">
  74.                                                         {{block("page_product_detail_buy_quantity_input", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
  75.                                                         {% if page.product.unit != null %}
  76.                                                             <input class="form-control w-25" type="text" placeholder="{{page.product.unit.name}}" readonly>
  77.                                                         {% endif %}
  78.                                                     </div>
  79.                                                 {% endblock %}
  80.                                                 {% block page_product_detail_buy_quantity_input_unit %}
  81.                                                     {{block("page_product_detail_buy_quantity_input_unit", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
  82.                                                 {% endblock %}
  83.                                             </div>
  84.                                         {% endblock %}
  85.                                     {% else %}
  86.                                         {% block page_product_detail_buy_quantity_select %}
  87.                                             <div class="d-flex">
  88.                                                 {{block("page_product_detail_buy_quantity_select", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
  89.                                                 {% if page.product.unit != null %}
  90.                                                     <input class="form-control w-25" type="text" placeholder="{{page.product.unit.shortCode}}" readonly>
  91.                                                 {% endif %}
  92.                                             </div>
  93.                                         {% endblock %}
  94.                                     {% endif %}
  95.                                 </div>
  96.                             {% endblock %}
  97.                         </div>
  98.                     {% endif %}
  99.                 {% endblock %}
  100.                 {% block page_product_detail_buy_redirect_input %}
  101.                     {# fallback redirect back to detail page is deactivated via js #}
  102.                     {{block("page_product_detail_buy_redirect_input", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
  103.                 {% endblock %}
  104.                 {% block page_product_detail_buy_product_buy_info %}
  105.                     {{block("page_product_detail_buy_product_buy_info", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
  106.                 {% endblock %}
  107.                 {% block page_product_detail_buy_button_container %}
  108.                     {# @fourtwosix-edit: FV: added check if can be ordered #}
  109.                     {% if canBeOrdered %}
  110.                         {% if enableUnitConversion %}
  111.                             {% if page.product.unit.translated.name != null && page.product.purchaseUnit != null %}
  112.                                 <div class="row mt-4 align-items-center">
  113.                                     <div class="col-12 col-md-6">
  114.                                         {{ "fourtwosix-qm.totalLabel"|trans}}
  115.                                         {# @fourtwosix-edit: FV: manipulate if price is shown #}
  116.                                         {% if showPrice %}
  117.                                         <b class="totalPrice">{{page.product.calculatedPrice.unitPrice|currency(page.product.price|first.currency.currencyId)}}</b>
  118.                                         {% endif %}
  119.                                     </div>
  120.                                     <div class="col-12 col-md-6">
  121.                                         <button class="btn btn-primary btn-block btn-buy" title="{{ "detail.addProduct"|trans|striptags }}" aria-label="{{ "detail.addProduct"|trans|striptags }}">
  122.                                             {{ "detail.addProduct"|trans|sw_sanitize }}
  123.                                         </button>
  124.                                     </div>
  125.                                 </div>
  126.                             {% else %}
  127.                                 {{block("page_product_detail_buy_button_container", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
  128.                             {% endif %}
  129.                         {% else %}
  130.                             <div class="col-12 col-md-8">
  131.                                 {% block page_product_detail_buy_button %}
  132.                                     {{block("page_product_detail_buy_button", "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig")}}
  133.                                 {% endblock %}
  134.                             </div>
  135.                         {% endif %}
  136.                     {% else %}
  137.                         {# @fourtwosix-edit: FV: Reuest quotation form #}
  138.                         <div class="form-row mt-4">
  139.                             <div class="form-group col-md-6">
  140.                                 <label for="requestQuotationNameSurname"> {{ 'fourtwosix.request.product.form.nameAndSurname'|trans|sw_sanitize }}</label>
  141.                                 <input required="required" type="text" class="form-control"
  142.                                        name="requestQuotationNameSurname" id="requestQuotationNameSurname">
  143.                             </div>
  144.                             <div class="form-group col-md-6">
  145.                                 <label for="requestQuotationEmail"> {{ 'fourtwosix.request.product.form.email'|trans|sw_sanitize }}</label>
  146.                                 <input required="required" type="email" class="form-control"
  147.                                        value="{{ context.customer.email }}" name="requestQuotationEmail"
  148.                                        id="requestQuotationEmail">
  149.                             </div>
  150.                             <div class="form-group col-md-4">
  151.                                 <label for="requestQuotationZipcode"> {{ 'fourtwosix.request.product.form.zipcode'|trans|sw_sanitize }}</label>
  152.                                 <input required="required" type="text" class="form-control"
  153.                                        name="requestQuotationZipcode" id="requestQuotationZipcode">
  154.                             </div>
  155.                             <div class="form-group col-md-8">
  156.                                 {% set countries = page.countries ? page.countries : page.extensions["FourtwosixShippingCostsCalculator"]["countries"].elements %}
  157.                                 <label for="requestQuotationCountry"> {{ 'fourtwosix.request.product.form.country'|trans|sw_sanitize }}</label>
  158.                                 <select class="form-select form-control" type="text" id="requestQuotationCountry"
  159.                                         name="requestQuotationCountry">
  160.                                     {% for country in countries %}
  161.                                         <option value="{{ country.translated.name }}"
  162.                                                 {{ country.id == context.shippingLocation.country.id ? 'selected="selected"' : '' }}>
  163.                                             {{ country.translated.name }}
  164.                                         </option>
  165.                                     {% endfor %}
  166.                                 </select>
  167.                             </div>
  168.                             <div class="form-group col-12">
  169.                                 <label for="requestQuotationMessage"> {{ 'fourtwosix.request.product.form.message'|trans|sw_sanitize }}</label>
  170.                                 <textarea required="required" class="form-control" id="requestQuotationMessage" name="requestQuotationMessage"
  171.                                           rows="5"></textarea>
  172.                             </div>
  173.                         </div>
  174.                         {# @fourtwosix-edit: FV hidden inputs #}
  175.                         <input required="required" type="hidden" name="requestQuotationProductNumber" value="{{ product.productNumber }}"/>
  176.                         <input required="required" type="hidden" name="requestQuotationProductUnit" value="{{ product.unit.translated.name }}"/>
  177.                         <input required="required" type="hidden" name="requestQuotationProducId" value="{{ product.id }}"/>
  178.                         <div class="row mt-4 align-items-center w-100">
  179.                             <div class="col-12 col-md-6">
  180.                                 {# @fourtwosix-edit: FV: manipulate if price is shown #}
  181.                                 {% if showPrice %}
  182.                                     {{ "fourtwosix-qm.totalLabel"|trans }}
  183.                                     <b class="totalPrice">{{ page.product.calculatedPrice.unitPrice|currency(page.product.price|first.currency.currencyId) }}</b>
  184.                                 {% endif %}
  185.                             </div>
  186.                             <div class="col-12  col-md-6">
  187.                                 <input class="btn btn-primary btn-block btn-buy"
  188.                                        type="submit"
  189.                                        value="{{ 'fourtwosix.request.product.price'|trans|striptags }}"
  190.                                        title="{{ 'fourtwosix.request.product.price'|trans|striptags }}"
  191.                                        aria-label="{{ 'fourtwosix.request.product.price'|trans|striptags }}"/>
  192.                             </div>
  193.                         </div>
  194.                     {% endif %}
  195.                 {% endblock %}
  196.             </div>
  197.         {% endif %}
  198.     {% endblock %}
  199. </form>
  200. {% endblock %}