custom/static-plugins/product-labels/src/Resources/views/storefront/component/product-label/badge-discount.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/component/product-label/badge.html.twig' %}
  2. {% block component_product_label_badge %}
  3.     {% set normalPrice = product.calculatedPrice.unitPrice %}
  4.     {% set salePrice = product.calculatedPrices.first.unitPrice %}
  5.     {% set badgeContent = "" %}
  6.     {% if salePrice and (normalPrice !== salePrice) %}
  7.         {% set saleInAmount = normalPrice - salePrice %}
  8.         {% set badgeContent = ((saleInAmount / normalPrice) * 100)|round(0) %}
  9.     {% endif %}
  10.     {% if badgeContent %}
  11.         {% set badgeContent = '-'~badgeContent~'%' %}
  12.         {{ parent() }}
  13.     {% endif %}
  14. {% endblock %}