custom/plugins/TdsOrlob/src/Resources/views/storefront/component/product/card/price-unit.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/component/product/card/price-unit.html.twig' %}
  2. {% block component_product_box_price %}
  3.     {% set variants = getVariants(product.parentId, context.context) %}
  4.     {# {% if not variants %}
  5.         single product<br>
  6.         {{dump(product.cheapestPrice.price|first.net|currency)}}
  7.     {% else %}
  8.         variant<br>
  9.         {% set parent = getProduct(variants|first.parentId, context.context) %}
  10.         {% set price = parent.entities %}
  11.         {{dump(price)}}
  12.     {% endif %} #}
  13.     {% if context.currentCustomerGroup.id != "cfbd5018d38d41d8adca10d94fc8bdd6" %}
  14.     
  15.         <div class="product-price-wrapper">
  16.             {# Set the price and conditions for list and regulation prices #}
  17.             {% set price = real %}
  18.             {% set isListPrice = price.listPrice.percentage > 0 %}
  19.             {% set isRegulationPrice = price.regulationPrice is not null %}
  20.             
  21.             <span class="product-price{% if isListPrice and not displayFrom and not displayFromVariants %} with-list-price{% endif %}">
  22.                 {% if variants %}Ab{% endif %}
  23.                 {{ price.unitPrice|currency }}
  24.                 
  25.                 {% if isListPrice and not displayFrom and not displayFromVariants %}
  26.                     {% set afterListPriceSnippetExists = "listing.afterListPrice"|trans|length > 0 %}
  27.                     {% set beforeListPriceSnippetExists = "listing.beforeListPrice"|trans|length > 0 %}
  28.                     {% set hideStrikeThrough = beforeListPriceSnippetExists or afterListPriceSnippetExists %}
  29.                     
  30.                     <span class="list-price{% if hideStrikeThrough %} list-price-no-line-through{% endif %}">
  31.                         {% if beforeListPriceSnippetExists %}
  32.                             {{ "listing.beforeListPrice"|trans|trim|sw_sanitize }}
  33.                         {% endif %}
  34.                         {% if afterListPriceSnippetExists %}
  35.                             {{ "listing.afterListPrice"|trans|trim|sw_sanitize }}
  36.                         {% endif %}
  37.                         <span class="list-price-percentage">
  38.                             {{ "detail.listPricePercentage"|trans({'%price%': price.listPrice.percentage})|sw_sanitize }}
  39.                         </span>
  40.                     </span>
  41.                 {% endif %}
  42.             </span>
  43.             
  44.             {% if isRegulationPrice %}
  45.                 <span class="product-price with-regulation-price">
  46.                     {% if isListPrice %}<br/>{% endif %}
  47.                     <span class="regulation-price">
  48.                         {{ "general.listPricePreviously"|trans({'%price%': price.regulationPrice.price|currency }) }}
  49.                     </span>
  50.                 </span>
  51.             {% endif %}
  52.         </div>
  53.     {% endif %}
  54.     
  55.     
  56.     
  57. {#         {{dump(product.categoryTree)}} #}
  58.         {# Initialize variables #}
  59.         {% set categoryTreeToSearch = product.categoryTree %}
  60.         {% set targetCategory = "b694a587db9a4145817b22779a409c08" %}
  61.         {% set categoryCount = categoryTreeToSearch|length %}
  62.         {% set categoryFound = false %}
  63.         
  64.         {# Loop through categoryTreeToSearch to find targetCategory #}
  65.         {% for category in categoryTreeToSearch %}
  66.             {% if category == targetCategory %}
  67.                 {% set categoryFound = true %}
  68.                 {% break %}
  69.             {% endif %}
  70.         {% endfor %}
  71.         
  72.         {# Debug output to ensure the variables are correct #}
  73. {#
  74.         Category Count: {{ categoryCount }}<br>
  75.         Category Found: {{ categoryFound ? 'Yes' : 'No' }}<br>
  76. #}
  77.         
  78.         
  79.         
  80.         
  81.         
  82. {#         {{dump(context.currentCustomerGroup.id)}} #}
  83.         
  84.         {# Final condition to display specific content #}
  85. {#         {% if categoryFound and categoryCount < 4 %} #}
  86. {#             <p style="color: #e52427; font-weight: 700;">Der Artikel wird gerade eingeführt und kann bald bestellt werden.</p> #}
  87.         {% if product %}
  88.             {% set variants = getVariants(product.parentId, context.context) %}
  89.             
  90.             {% set totalStock = 0 %}
  91.             {% set hasVariants = variants|length > 0 %}
  92.             
  93.             {% for variant in variants %}
  94.                 {% set stock = variant.availableStock %}
  95.                 {% if stock < 0 %}
  96.                     {% set stock = 0 %}
  97.                 {% endif %}
  98.                 {# StockVariant: {{ stock }} <br> #}
  99.                 {% set totalStock = totalStock + stock %}
  100.             {% endfor %}
  101.             
  102.             {% if not hasVariants %}
  103.                 {% set totalStock = totalStock + product.stock %}
  104.             {% endif %}
  105.             {# <b>Total Stock: {{ totalStock }}</b> #}
  106.             
  107.             
  108.             <div class="product-available">
  109.                 {% if context.currentCustomerGroup.id == "cfbd5018d38d41d8adca10d94fc8bdd6" %}
  110.                     {% if totalStock > 20 %}
  111.                         <span class="traffic green">
  112.                             <span class="dot green"></span>
  113.                             {{ 'available.verfuegbar'|trans }}
  114.                         </span>
  115.                     {% elseif totalStock > 0 %}
  116.                         <span class="traffic yellow">
  117.                             <span class="dot yellow"></span>
  118.                             {{ 'available.wenige_verfuegbar'|trans }}
  119.                         </span>
  120.                     {% else %}
  121.                         <span class="traffic red">
  122.                             <span class="dot red"></span>
  123.                             {{ 'available.nicht_verfuegbar'|trans }}
  124.                         </span>
  125.                     {% endif %}
  126.                 {% else %}
  127.                     {% if totalStock > 150 %}
  128.                         <span class="traffic green">
  129.                             <span class="dot green"></span>
  130.                             {{ 'available.mehr_als_150_stueck_verfuegbar'|trans }}
  131.                         </span>
  132.                     {% elseif totalStock > 20 %}
  133.                         <span class="traffic green">
  134.                             <span class="dot green"></span>
  135.                             {{ totalStock }} {{ 'available.verfuegbar'|trans }}
  136.                         </span>
  137.                         
  138.                     {% elseif totalStock > 0 %}
  139.                         <span class="traffic yellow">
  140.                             <span class="dot yellow"></span>
  141.                             {{ 'available.nurnoch'|trans }} {{ totalStock }} {{ 'available.verfuegbar'|trans }}
  142.                         </span>
  143.                     {% else %}
  144.                         <span class="traffic red">
  145.                             <span class="dot red"></span>
  146.                             {{ 'available.nicht'|trans }} {{ 'available.verfuegbar'|trans }}
  147.                         </span>
  148.                     {% endif %}
  149.                 {% endif %}
  150.             </div>
  151.         
  152.             <div class="releasedate">
  153.                 {% if product.releaseDate && totalStock == 0 %}
  154.                         <span class="dot yellow"></span> Wieder lieferbar ab {{ product.releaseDate|format_date('long', locale=app.request.locale) }}
  155.                 {% endif %}
  156.             </div>
  157.         {% endif %}
  158. {% endblock %}
  159. {% block component_product_box_price_unit %}
  160. {% endblock %}