How to hide discount amount in the PDF Template if it is equal to zero?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Triggerz
    Senior Member
    • May 2024
    • 139

    #1

    How to hide discount amount in the PDF Template if it is equal to zero?

    Hi,

    I am trying to hide the discount amount in the PDF Template if the value is equal to zero. I tried the following codes but I could not make it work.


    This code displays the amount even if the discount is equal to zero
    Code:
    {{#if (notEqual discountAmount 0)}}
       <tr>
          <td colspan="5" align="right">Discount Amount</td>
          <td align="right">{{discountAmount}}</td>
       </tr>
    {{/if}}
    ​
    I also tried using x-if but could not make it work as well. The code below still displays the discount even if the value of discount is zero.

    Code:
     <tr x-if="{{notEqual discountAmount 0}}">
         <td colspan="5" align="right">Discount Amount</td>
         <td align="right">{{discountAmount}}</td>
     </tr>​

    Please help.

    Thanks in advance...
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9658

    #2
    Hi,

    Did you try:


    Code:
    x-if="{{discountAmount}}"

    Comment

    • Triggerz
      Senior Member
      • May 2024
      • 139

      #3
      Hi yuri, I tried it but it still displays the Discount even if it is zero.

      Code:
      <tr x-if="{{discountAmount}}">
      <td colspan="5" align="right">Discount Amount</td>
      <td align="right">{{discountAmount}}</td>
      </tr>

      Comment

      • yuri
        EspoCRM product developer
        • Mar 2014
        • 9658

        #4
        I think you need {{discountAmount_RAW}}, as the {{discountAmount}} prints a string with a zero which is not resolved to false.

        Comment

        • Triggerz
          Senior Member
          • May 2024
          • 139

          #5
          Hi yuri, thank you so much. That actually worked

          Comment

          Working...