discount in % in order template

sspindsspind Member Posts: 13

I would like to have the discount in the order template always in percent (%). My idea would be

{{ product.unitprice/product.discount }}%


But this doesnt work. Any ideas? Thanks in advance!

1 comment

  • JulienDJulienD Member, Moderator, Lightspeed Staff Posts: 25 moderator

    Hello @sspind ,

    This is the code Lightspeed support suggest to do so:

    {% set discountBare = product.discount | replace({" ": "", "€": "", ",": "."}) %}
    {% set priceBare = product.unitprice | replace({" ": "", "€": "", ",": "."}) %}
     
    {% if discountBare != 0 and priceBare != 0 %}
     <td>{{ ((discountBare / priceBare) * 100) | round(2) }}%</td>
    {% else %}
     <td></td>
    {% endif %}
    {# <td>{{ product.discount }}</td> #}
    


    Hope this works for you!

    Have a good day!

    eCom Support

    Lightspeed HQ

Sign In or Register to comment.