templates/default/components/organisms/variant-selection/variant-selection.html.twig line 1

Open in your IDE?
  1. {% set variantNotAvailable = variant.salesStatus is defined and
  2. variant.salesStatus == constant('App\\Constant\\SalesStatus::SALE_STATUS_TEMPORARY_NOT_AVAILABLE') %}
  3. {% if product.variants | length > 1 or variant.variantSelections|default([])|length > 1 %}
  4. <div class="variant-selection" >
  5. {% block buyBoxVariants %}
  6. {% if isPunchout %}
  7. {% if product.variants | length > 1 %}
  8. {% set currentVariantSku = variant.sku %}
  9. {% embed 'components/atoms/select/select.html.twig'
  10. with {
  11. 'class': 'js-auto-route js-page-loader-change',
  12. 'id': 'punchoutVariantSelection',
  13. 'name': 'punchoutVariantSelection',
  14. 'options': product.variants,
  15. } %}
  16. {% block options %}
  17. {% for variant in product.variants %}
  18. {% if variant.salesStatus == "saleable" and variant.attributes.price is not empty and variant.attributes.price != 0 %}
  19. <option
  20. value="{{ variant.links.webshop }}"
  21. {% if variant.sku == currentVariantSku %}
  22. selected="selected"
  23. {% endif %}
  24. >
  25. {{ variant.variantSelections| first }}
  26. </option>
  27. {% endif %}
  28. {% endfor %}
  29. {% endblock %}
  30. {% endembed %}
  31. {% endif %}
  32. {% else %}
  33. {% if variant.variantSelections|default %}
  34. {% for variantSelection in variant.variantSelections %}
  35. {% if variantSelection.type is defined and variantSelection.type == 'tile' %}
  36. <div class="variant-selection__color">
  37. <p class="variant-selection__color-text">
  38. {{ variantSelection.label|default('product_select_color'|trans) }}: {{ (variantSelection.options|filter(o => o.selected == true)|first).name }}
  39. </p>
  40. <div class="variant-selection__variant variant-selection__variant--color">
  41. {% set sortedOptions = variantSelection.options|sort((a, b) => a.name <=> b.name) %}
  42. {% for key, option in sortedOptions %}
  43. {% include 'components/atoms/color-input/color-input.html.twig' with {
  44. 'selected': option.selected,
  45. 'name': option.name,
  46. 'href': option.value,
  47. 'hex': ('variant_selection_color_' ~ option.key)|trans
  48. } %}
  49. {% endfor %}
  50. </div>
  51. </div>
  52. {% endif %}
  53. {% if variantSelection.type is defined and variantSelection.type == 'select' %}
  54. <div class="variant-selection__variant">
  55. <div class="form-row form-row--floating">
  56. {% embed 'components/atoms/select/select.html.twig'
  57. with {
  58. 'class': 'js-auto-route js-page-loader-change',
  59. 'id': variantSelection.name|default,
  60. 'name': variantSelection.name|default,
  61. 'options': variantSelection.options,
  62. } %}
  63. {% block options %}
  64. {% for option in variantSelection.options %}
  65. <option
  66. value="{{ option.value }}"
  67. {% if option.selected %}selected{% endif %}
  68. {% if not option.saleable or not option.sameAttributeSet %}
  69. class="gray"
  70. {% if not option.saleable %}
  71. title="{{ 'buy_box_variant_not_available'|trans }}"
  72. {% else %}
  73. title="{{ 'buy_box_variant_not_same_attribute_set'|trans }}"
  74. {% endif %}
  75. {% endif %}
  76. >
  77. {{ option.name }}
  78. </option>
  79. {% endfor %}
  80. {% endblock %}
  81. {% endembed %}
  82. <label for="{{ variantSelection.name }}" class="form-row__label" data-content="{{ variantSelection.label|default|prepare_for_css_content_attribute }}">
  83. <span class="form-row__hidden-visually">{{ variantSelection.label|default }}</span>
  84. </label>
  85. </div>
  86. </div>
  87. {% endif %}
  88. {% endfor %}
  89. {% endif %}
  90. {% endif %}
  91. {% endblock %}
  92. {% block buyBoxOptions %}
  93. {% if product.productOptions|default %}
  94. {% include 'components/atoms/button/button.html.twig' with {
  95. 'type': 'button',
  96. 'class': 'button--select js-offside',
  97. 'content': 'buy_box_select_option'|trans,
  98. 'attributes': {
  99. 'data-offside-component': 'productOptions',
  100. 'data-offside-sliding-side': 'right'
  101. }
  102. } %}
  103. {% embed 'components/organisms/offside/offside.html.twig' with {
  104. 'id': 'productOptions',
  105. 'header': 'buy_box_select_option'|trans
  106. } %}
  107. {% block content %}
  108. {% block offcanvasContent %}
  109. {% for productOption in product.productOptions %}
  110. <p>{{ productOption.name }}</p>
  111. {% endfor %}
  112. {% endblock %}
  113. {% endblock %}
  114. {% endembed %}
  115. {% endif %}
  116. {% endblock %}
  117. </div>
  118. {% endif %}