{% sw_extends '@parent/storefront/component/product/card/action.html.twig' %}
{% block component_product_box_action_buy %}
{% set nb_is_por = product.extensions.nimbits_por.is_por %}
{% set nb_is_purchaseable = product.extensions.nimbits_por.is_purchaseable %}
{% set nb_show_price = product.extensions.nimbits_por.show_price %}
{% set customizedProductsTemplate = product.extensions.swagCustomizedProductsTemplate %}
{% set por_btn_visible = product.extensions.nimbits_por_product_ruleset.por_btn_visible %}
{% set por_dont_show_price = product.extensions.nimbits_por_product_ruleset.por_dont_show_price %}
{% set por_add_to_cart_not_visible = product.extensions.nimbits_por_product_ruleset.por_add_to_cart_not_visible %}
{% set por_product_not_purchasable = product.extensions.nimbits_por_product_ruleset.por_product_not_purchasable %}
{% if por_btn_visible or por_dont_show_price or por_add_to_cart_not_visible or por_product_not_purchasable %}
{% if por_product_not_purchasable %}
{# {% do page.extensions.payPalEcsButtonData.assign({'listingEnabled': false }) %} #}
{# todo paypal settings #}
{% endif %}
{% if por_dont_show_price %}
{# {% do page.extensions.payPalEcsButtonData.assign({'listingEnabled': false }) %} #}
{# todo paypal settings #}
{% endif %}
{% if not por_add_to_cart_not_visible %}
{{ parent() }}
{% endif %}
{% block nimbits_por_product_box_action_buy_visible %}
{% if por_btn_visible %}
{% set nbPriceRequestItems = [] %}
{% set nbPriceRequestItems = nbPriceRequestItems|merge([{ quantity: 1, number: product.productNumber, name: product.translated.name }]) %}
<input type="hidden" name="redirectParameters" data-redirect-parameters="true"
value='{"productId": "{{ product.id }}"}'>
<input type="hidden" name="lineItems[{{ id }}][id]" value="{{ id }}">
<input type="hidden" name="lineItems[{{ id }}][referencedId]" value="{{ id }}">
<input type="hidden" name="lineItems[{{ id }}][type]" value="product">
<input type="hidden" name="lineItems[{{ id }}][stackable]" value="1">
<input type="hidden" name="lineItems[{{ id }}][removable]" value="1">
<input type="hidden" name="lineItems[{{ id }}][quantity]" value="1">
<input type="hidden" name="product-name" value="{{ product.translated.name }}">
<button
class="btn btn-block btn-buy btn-nb-pricerequest-listing"
title="{{ 'nimbits-pricerequests.listing.button.openrequestform'|trans }}"
data-toggle="modal"
data-ajax-modal
data-url="{{ path('frontend.action.nimbits.price-request-modal') }}">
{{ 'nimbits-pricerequests.listing.button.openrequestform'|trans }}
<input name="nb_pricerequest_lineitems" type="hidden"
value="{{ nbPriceRequestItems|json_encode() }}"/>
</button>
{% endif %}
{% endblock %}
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}