custom/static-plugins/LDSCustom/src/Resources/views/storefront/component/product/card/badges.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/component/product/card/badges.html.twig' %}
  2. {# TODO: @zenit check on sw update #}
  3. {# Discount badge with Percentage #}
  4.     {% block component_product_badges_discount %}
  5.     {# ThemeWare: Set theme variables #}
  6.     {% set twtProductBadgesDiscountBadgeColoration = theme_config('twt-product-badges-discount-badge-coloration') %}
  7.     {% set twtProductBadgesDiscountBadgeRound = theme_config('twt-product-badges-discount-badge-round') %}
  8.     {% set twtProductBadgesDiscountBadgeType = theme_config('twt-product-badges-discount-badge-type') %}
  9.     {# ---------------- END: SET TEMPLATE VARS ---------------- #}
  10.     {% set price = product.calculatedPrice %}
  11.         {% if product.calculatedPrices.count > 0 %}
  12.     {% set price = product.calculatedPrices.last %}
  13.     {% endif %}
  14.     {% set listPrice = price.listPrice.percentage > 0 %}
  15.     {% set hasRange = product.calculatedPrices.count > 1 %}
  16.         {% if product.calculatedPrice.listPrice.percentage >= 10 %}
  17.             {% if twtProductBadgesDiscountBadgeType == 1 %}
  18.             {# % #}
  19.                 <div>
  20.                     <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount"> &#37;
  21.                 </span>
  22.             </div>
  23.         {% elseif twtProductBadgesDiscountBadgeType == 2 %}
  24.             {# -20% #}
  25.             <div>
  26.                 <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount">
  27.                     {% if twtProductBadgesDiscountBadgeRound == 1 %}
  28.                         -{{ "twt.extension.discountBadge.percentageShort"|trans({'%discount%': product.calculatedPrice.listPrice.percentage })|sw_sanitize }}
  29.                     {% elseif twtProductBadgesDiscountBadgeRound == 2 %}
  30.                         -{{ "twt.extension.discountBadge.percentageShort"|trans({'%discount%': product.calculatedPrice.listPrice.percentage|round(1, 'floor') })|sw_sanitize }}
  31.                     {% elseif twtProductBadgesDiscountBadgeRound == 3 %}
  32.                         -{{ "twt.extension.discountBadge.percentageShort"|trans({'%discount%': product.calculatedPrice.listPrice.percentage|round })|sw_sanitize  }}
  33.                     {% endif %}
  34.                 </span>
  35.             </div>
  36.         {% elseif twtProductBadgesDiscountBadgeType == 3 %}
  37.             {# 20% saved #}
  38.             <div>
  39.                 <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount">
  40.                     {% if twtProductBadgesDiscountBadgeRound == 1 %}
  41.                         {{ "twt.extension.discountBadge.percentage"|trans({'%discount%': product.calculatedPrice.listPrice.percentage })|sw_sanitize }}
  42.                     {% elseif twtProductBadgesDiscountBadgeRound == 2 %}
  43.                         {{ "twt.extension.discountBadge.percentage"|trans({'%discount%': product.calculatedPrice.listPrice.percentage|round(1, 'floor') })|sw_sanitize }}
  44.                     {% elseif twtProductBadgesDiscountBadgeRound == 3 %}
  45.                         {{ "twt.extension.discountBadge.percentage"|trans({'%discount%': product.calculatedPrice.listPrice.percentage|round })|sw_sanitize }}
  46.                     {% endif %}
  47.                 </span>
  48.             </div>
  49.         {% elseif twtProductBadgesDiscountBadgeType == 4 %}
  50.             {# -35 € #}
  51.             <div>
  52.                 <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount">
  53.                     {% if twtProductBadgesDiscountBadgeRound == 1 %}
  54.                         {{ "twt.extension.discountBadge.discountShort"|trans({'%discount%': product.calculatedPrice.listPrice.discount, '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  55.                     {% elseif twtProductBadgesDiscountBadgeRound == 2 %}
  56.                         {{ "twt.extension.discountBadge.discountShort"|trans({'%discount%': product.calculatedPrice.listPrice.discount|round(1, 'floor'), '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  57.                     {% elseif twtProductBadgesDiscountBadgeRound == 3 %}
  58.                         {{ "twt.extension.discountBadge.discountShort"|trans({'%discount%': product.calculatedPrice.listPrice.discount|round, '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  59.                     {% endif %}
  60.                 </span>
  61.             </div>
  62.         {% elseif twtProductBadgesDiscountBadgeType == 5 %}
  63.             {# 35 € saved #}
  64.             <div>
  65.                 <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount">
  66.                     {% if twtProductBadgesDiscountBadgeRound == 1 %}
  67.                         {{ "twt.extension.discountBadge.discount"|trans({'%discount%': product.calculatedPrice.listPrice.discount, '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  68.                     {% elseif twtProductBadgesDiscountBadgeRound == 2 %}
  69.                         {{ "twt.extension.discountBadge.discount"|trans({'%discount%': product.calculatedPrice.listPrice.discount|round(1, 'floor'), '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  70.                     {% elseif twtProductBadgesDiscountBadgeRound == 3 %}
  71.                         {{ "twt.extension.discountBadge.discount"|trans({'%discount%': product.calculatedPrice.listPrice.discount|round, '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  72.                     {% endif %}
  73.                 </span>
  74.             </div>
  75.         {% endif %}
  76.     {% endif %}
  77. {% endblock %}