custom/plugins/TcinnThemeWareClean/src/Resources/views/storefront/themeware/includes/twt-badge-discount-include.html.twig line 1

Open in your IDE?
  1. {# ThemeWare "Discount badge" content #}
  2. {# TODO: Blöcke prüfen... #}
  3. {# TODO: Add tooltip when values were rounded?  [data-toggle="tooltip" data-placement="right" title="Tooltip on right"] #}
  4. {# ---------------- START: SET TEMPLATE VARS ---------------- #}
  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 listPrice and not hasRange %}
  17.     {% block twt_product_badges_discount_badge %}
  18.         {% if twtProductBadgesDiscountBadgeType == 1 %}
  19.             {# % #}
  20.             <div>
  21.                 <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount">
  22.                     &#37;
  23.                 </span>
  24.             </div>
  25.         {% elseif twtProductBadgesDiscountBadgeType == 2 %}
  26.             {# -20% #}
  27.             <div>
  28.                 <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount">
  29.                     {% if twtProductBadgesDiscountBadgeRound == 1 %}
  30.                         -{{ "twt.extension.discountBadge.percentageShort"|trans({'%discount%': product.calculatedPrice.listPrice.percentage })|sw_sanitize }}
  31.                     {% elseif twtProductBadgesDiscountBadgeRound == 2 %}
  32.                         -{{ "twt.extension.discountBadge.percentageShort"|trans({'%discount%': product.calculatedPrice.listPrice.percentage|round(1, 'floor') })|sw_sanitize }}
  33.                     {% elseif twtProductBadgesDiscountBadgeRound == 3 %}
  34.                         -{{ "twt.extension.discountBadge.percentageShort"|trans({'%discount%': product.calculatedPrice.listPrice.percentage|round })|sw_sanitize  }}
  35.                     {% endif %}
  36.                 </span>
  37.             </div>
  38.         {% elseif twtProductBadgesDiscountBadgeType == 3 %}
  39.             {# 20% saved #}
  40.             <div>
  41.                 <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount">
  42.                     {% if twtProductBadgesDiscountBadgeRound == 1 %}
  43.                         {{ "twt.extension.discountBadge.percentage"|trans({'%discount%': product.calculatedPrice.listPrice.percentage })|sw_sanitize }}
  44.                     {% elseif twtProductBadgesDiscountBadgeRound == 2 %}
  45.                         {{ "twt.extension.discountBadge.percentage"|trans({'%discount%': product.calculatedPrice.listPrice.percentage|round(1, 'floor') })|sw_sanitize }}
  46.                     {% elseif twtProductBadgesDiscountBadgeRound == 3 %}
  47.                         {{ "twt.extension.discountBadge.percentage"|trans({'%discount%': product.calculatedPrice.listPrice.percentage|round })|sw_sanitize }}
  48.                     {% endif %}
  49.                 </span>
  50.             </div>
  51.         {% elseif twtProductBadgesDiscountBadgeType == 4 %}
  52.             {# -35 € #}
  53.             <div>
  54.                 <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount">
  55.                     {% if twtProductBadgesDiscountBadgeRound == 1 %}
  56.                         {{ "twt.extension.discountBadge.discountShort"|trans({'%discount%': product.calculatedPrice.listPrice.discount, '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  57.                     {% elseif twtProductBadgesDiscountBadgeRound == 2 %}
  58.                         {{ "twt.extension.discountBadge.discountShort"|trans({'%discount%': product.calculatedPrice.listPrice.discount|round(1, 'floor'), '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  59.                     {% elseif twtProductBadgesDiscountBadgeRound == 3 %}
  60.                         {{ "twt.extension.discountBadge.discountShort"|trans({'%discount%': product.calculatedPrice.listPrice.discount|round, '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  61.                     {% endif %}
  62.                 </span>
  63.             </div>
  64.         {% elseif twtProductBadgesDiscountBadgeType == 5 %}
  65.             {# 35 € saved #}
  66.             <div>
  67.                 <span class="badge badge-danger{% if twtProductBadgesDiscountBadgeColoration == 3 %}-lighten{% endif %} badge-discount twt-badge-discount">
  68.                     {% if twtProductBadgesDiscountBadgeRound == 1 %}
  69.                         {{ "twt.extension.discountBadge.discount"|trans({'%discount%': product.calculatedPrice.listPrice.discount, '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  70.                     {% elseif twtProductBadgesDiscountBadgeRound == 2 %}
  71.                         {{ "twt.extension.discountBadge.discount"|trans({'%discount%': product.calculatedPrice.listPrice.discount|round(1, 'floor'), '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  72.                     {% elseif twtProductBadgesDiscountBadgeRound == 3 %}
  73.                         {{ "twt.extension.discountBadge.discount"|trans({'%discount%': product.calculatedPrice.listPrice.discount|round, '%currency%': page.header.activeCurrency.symbol })|sw_sanitize }}
  74.                     {% endif %}
  75.                 </span>
  76.             </div>
  77.         {% endif %}
  78.     {% endblock %}
  79. {% endif %}