custom/static-plugins/NdVoorwindenTheme/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/component/buy-widget/buy-widget-form.html.twig' %}
  2. {% block buy_widget_buy_container %}
  3.     {% set buyable = product.available and product.calculatedMaxPurchase > 0 %}
  4.     <div class="buy-widget-container flex grid-gap-2">
  5.         <div class="{% if buyable %}grid-gap-2{% endif %} {% if config('core.cart.wishlistEnabled') %}{% endif %}">
  6.             {% if buyable %}
  7.                 {% block buy_widget_buy_quantity_container %}
  8.                 {% endblock %}
  9.                 {% block buy_widget_buy_redirect_input %}
  10.                     {{ parent() }}
  11.                 {% endblock %}
  12.                 {% block buy_widget_buy_product_buy_info %}
  13.                     {{ parent() }}
  14.                 {% endblock %}
  15.                 {% block buy_widget_product_buy_meta %}
  16.                     {{ parent() }}
  17.                 {% endblock %}
  18.             {% endif %}
  19.             {% if config('core.cart.wishlistEnabled') %}
  20.                 {% block buy_widget_wishlist %}
  21.                     {% sw_include '@Storefront/storefront/component/product/card/wishlist.html.twig' with {
  22.                         showText: false,
  23.                         size: 'sm',
  24.                         productId: product.id
  25.                     } %}
  26.                 {% endblock %}
  27.             {% endif %}
  28.         </div>
  29.         {% block buy_widget_buy_button %}
  30.             {# Custom code to check if all variants are OOS, if so: Set buyable to false #}
  31.             {% if buyable %}
  32.                 {% if options is null %}
  33.                     {% set options = page.product.children %}
  34.                 {% endif %}
  35.                 {% set allOut = true %}
  36.                 {% for key, option in options %}
  37.                     {% set outOfStock = option.stock <= 0 %}
  38.                     {% if not outOfStock %}
  39.                          {% set allOut = false %}
  40.                         {% break %}
  41.                     {% endif %}
  42.                 {% endfor %}
  43.                 {% if allOut %}
  44.                     {% set buyable = false %}
  45.                 {% endif %}
  46.             {% endif %}
  47.             {# End of custom code #}
  48.             <button class="btn btn-primary btn-block btn-primary w-full {% if not buyable %}disabled{% endif %}"
  49.                     data-product-add-to-cart-button="true"
  50.                     title="{% if buyable %}{{ "detail.addProduct"|trans|striptags }}{% else %}{{ "detail.soldOut"|trans|sw_sanitize }}{% endif %}"
  51.                     aria-label="{% if buyable %}{{ "detail.addProduct"|trans|striptags }}{% else %}{{ "detail.soldOut"|trans|sw_sanitize }}{% endif %}"
  52.                     {% if not buyable %}disabled="disabled"{% endif %}>
  53.                 {% sw_icon 'cart-solid' style {'pack': 'hero', 'class': ' white w-5'} %}
  54.                 {% if buyable %}
  55.                     {{ "detail.addProduct"|trans|sw_sanitize }}
  56.                 {% else %}
  57.                     {{ "detail.soldOut"|trans|sw_sanitize }}
  58.                 {% endif %}
  59.             </button>
  60.         {% endblock %}
  61.     </div>
  62. {% endblock %}