custom/plugins/NetzpEvents6/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. {% block page_product_detail_buy_container %}
  3.     {% set eventmain = page.product.extension('event') %}
  4.     {% set eventparent = page.product.extension('eventparent') %}
  5.     {% if eventmain %}
  6.         {% set event = eventmain %}
  7.     {% else %}
  8.         {% set event = eventparent %}
  9.     {% endif %}
  10.     {% set maxPlaces = 0 %}
  11.     {% set atLeastOneSlotWithPlaces = false %}
  12.     {% if event.bookable %}
  13.         {% if event.slots|length > 0 %}
  14.             {% block events_product_event_title %}
  15.                 <h4 class="d-inline">{{ event.translated.title }}</h4>
  16.             {% endblock %}
  17.             {% block events_product_event_badge %}
  18.                 <div class="badge badge-success float-right mt-1">
  19.                     {{ 'netzp.events.eventsBadge'|trans }}
  20.                 </div>
  21.             {% endblock %}
  22.             <ul class="list-group mt-2 mb-3" style="max-height: 23rem; overflow-y: auto">
  23.                 {% for slot in event.slots %}
  24.                     {% set ticketsAvailable = slot.ticketsAvailable - slot.ticketsBooked %}
  25.                     {% if ticketsAvailable > 0 %}
  26.                         {% set atLeastOneSlotWithPlaces = true %}
  27.                     {% endif %}
  28.                     {% if event.slots|length == 1 or app.request.get('slotId') == slot.id %}
  29.                         {% set maxPlaces = ticketsAvailable %}
  30.                     {% elseif maxPlaces == 0 %}
  31.                         {% set maxPlaces = 1 %}
  32.                     {% endif %}
  33.                     {% set showSlot = true %}
  34.                     {% if app.request.get('only') == 1 %}
  35.                         {% set showSlot = app.request.get('slotId') == slot.id %}
  36.                     {% endif %}
  37.                     {% block events_product_event_slots %}
  38.                         {% if showSlot %}
  39.                             <li class="list-group-item list-group-item-light">
  40.                                 <div class="form-check mb-2">
  41.                                     <input type="radio" required
  42.                                            class="form-check-input"
  43.                                            id="netzpEvent_{{ slot.id }}"
  44.                                            name="netzpEventId"
  45.                                            value="{{ slot.id }}"
  46.                                            onchange="reloadPageWithSlot('{{ slot.id }}')"
  47.                                            {% if ticketsAvailable <= 0 %}disabled{% endif %}
  48.                                            {% if ticketsAvailable > 0 and ((event.slots|length == 1) or (app.request.get('slotId') == slot.id)) %}checked{% endif %}
  49.                                     >
  50.                                     <label class="form-check-label" for="netzpEvent_{{ slot.id }}">
  51.                                         {% sw_include "@Storefront/storefront/event.html.twig" with { 'event': event, 'slot': slot, 'showTitle': false } only %}
  52.                                     </label>
  53.                                 </div>
  54.                             </li>
  55.                         {% endif %}
  56.                     {% endblock %}
  57.                 {% endfor %}
  58.             </ul>
  59.         {% endif %}
  60.         {% if not atLeastOneSlotWithPlaces %}
  61.             <span class="badge badge-warning mb-3">
  62.                 {{ "netzp.events.msg.noslots"|trans }}
  63.             </span>
  64.         {% else %}
  65.             {% do product.setCalculatedMaxPurchase(min(100, maxPlaces)) %}
  66.             {{ parent() }}
  67.         {% endif %}
  68.     {% else %}
  69.         {{ parent() }}
  70.     {% endif %}
  71.     <script>
  72.         function reloadPageWithSlot(id) {
  73.             var url = location.protocol + '//' + location.host + location.pathname + '?slotId=' + id;
  74.             window.location.href = url;
  75.         }
  76.     </script>
  77. {% endblock %}