Answers.Body: <p>I've edited the message template and used a <code>truncate</code> filter on the <code>$line.label</code> to hide the discount code. Something like this is what I've done:</p>
  
  <pre><code>&lt;td {$tdfirstStyle}&gt;
  {* Truncate $line.label to hide a discount code if present for certain event types *}
  {if $event.event_type_id == 12}
    {if $line.html_type eq'Text'}
      {$line.label|truncate:7:"":false:false}
    {else}
      {$line.field_title} - {$line.label|truncate:7:"":false:false}
    {/if}
  {else}
    {if $line.html_type eq 'Text'}
      {$line.label}
    {else}
      {$line.field_title} - {$line.label}
    {/if}
  {/if}
  {if $line.description}
    &lt;div&gt;{$line.description|truncate:30:"..."}&lt;/div&gt;
  {/if}
  &lt;/td&gt;
  </code></pre>
  
  <p>I think for this to work cleanly you might need to have Fee Levels with names of similar character count. There might be some other output filter that would work better than <code>truncate</code>... I recall trying to use some sort of RegEx filter that didn't work.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-29T17:55:53.597Z
Answers.LastActivityDate: 2019-08-29T17:55:53.597Z
Answers.UserDisplayName: Evan
Body: <p>We use discount codes widely for our events, including the use of what I'd call 'admin-only' codes so that we can apply discounts to registrations that we make on behalf of people like speakers, representatives of event sponsors, etc.</p>
  
  <p>Whilst it is helpful to to clearly show in the receipt/confirmation email that the event fee has been discounted, we don't really want the code itself to be included, as this is an internal code and not for wider use.</p>
  
  <p>Is there a way to suppress the inclusion of the code in the receipt, perhaps still allowing the description text for the code to be included?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-23T19:55:27.053Z
Comments.Text: You can modify the receipt by going to Mailings>Message Templates>System Workflow Messages tab>Events - Registration Confirmation and Receipt (on-line). CiviDiscount seems to modify the string in the 'Fee Level' field itself when the code is applied, which looks like it's just printed as a whole in the template, so someone would need to be quite clever to break out those pieces and achieve what you are asking, I think.
Comments.UserDisplayName: Eli Lisseck
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-26T07:17:11.990Z
Comments.Text: Thanks Eli. Do others feel that publishing the discount code itself in this way is a potential security issue?
Comments.UserDisplayName: Graham
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-11-14T20:21:45.357Z
Comments.Text: Actually it doesn't make sense at all for the code or the description for the code to be included in the receipt that is sent to the user. By all means it should be recorded as part of the contribution record so that administrators have visibility of the codes that are being used, but I can't see any compelling rationale to include it in the receipt.
Comments.UserDisplayName: Graham
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-11-14T20:36:47.970Z
Comments.Text: I agree with you and my gut instinct says it's only in the receipt because of the way civiDiscount modifies the fee level string to record the code use (fee level probably should be in the receipt because usually it denotes the event item or what have you purchased). I'm stuck short of a really great system in a few places with the functionality of civiDiscount (which we rely on quite heavily for complex events), including this piece, but i'm just not there yet in terms of programming (or budget) to take a stab at them, if they are even possible.
Comments.UserDisplayName: Eli Lisseck
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-11-14T20:39:35.387Z
Comments.Text: I've logged it as an issue here: https://github.com/dlobo/org.civicrm.module.cividiscount/issues/166
Comments.UserDisplayName: Graham
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-11-14T20:48:55.703Z
Comments.Text: Another thought i've just had: You might be able to do something clever with hook_civicrm_alterMailParams to strip out the discount code from your receipts after the token has been filled but before mail is sent. Seems like a lot of work and i'm not even sure it will work smoothly in the end :). https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterMailParams
Comments.UserDisplayName: Eli Lisseck
Tags: <cividiscount>
Title: How can I suppress the presentation of discount codes in receipts?
ThreadText: # How can I suppress the presentation of discount codes in receipts?
  
  (Asked by: username_0 on 2016-09-22)
  
  We use discount codes widely for our events, including the use of what I'd call 'admin-only' codes so that we can apply discounts to registrations that we make on behalf of people like speakers, representatives of event sponsors, etc.
  
  Whilst it is helpful to to clearly show in the receipt/confirmation email that the event fee has been discounted, we don't really want the code itself to be included, as this is an internal code and not for wider use.
  
  Is there a way to suppress the inclusion of the code in the receipt, perhaps still allowing the description text for the code to be included?
  
  **Tags:** cividiscount
  
  > **Comments:**
  > **username_1**: You can modify the receipt by going to Mailings>Message Templates>System Workflow Messages tab>Events - Registration Confirmation and Receipt (on-line). CiviDiscount seems to modify the string in the 'Fee Level' field itself when the code is applied, which looks like it's just printed as a whole in the template, so someone would need to be quite clever to break out those pieces and achieve what you are asking, I think.  
  > **username_0**: Thanks Eli. Do others feel that publishing the discount code itself in this way is a potential security issue?  
  > **username_0**: Actually it doesn't make sense at all for the code or the description for the code to be included in the receipt that is sent to the user. By all means it should be recorded as part of the contribution record so that administrators have visibility of the codes that are being used, but I can't see any compelling rationale to include it in the receipt.  
  > **username_1**: I agree with you and my gut instinct says it's only in the receipt because of the way civiDiscount modifies the fee level string to record the code use (fee level probably should be in the receipt because usually it denotes the event item or what have you purchased). I'm stuck short of a really great system in a few places with the functionality of civiDiscount (which we rely on quite heavily for complex events), including this piece, but i'm just not there yet in terms of programming (or budget) to take a stab at them, if they are even possible.  
  > **username_0**: I've logged it as an issue here: https://github.com/dlobo/org.civicrm.module.cividiscount/issues/166  
  > **username_1**: Another thought i've just had: You might be able to do something clever with hook_civicrm_alterMailParams to strip out the discount code from your receipts after the token has been filled but before mail is sent. Seems like a lot of work and i'm not even sure it will work smoothly in the end :). https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterMailParams  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-08-29. Score: 2
  
  I've edited the message template and used a `truncate` filter on the `$line.label` to hide the discount code. Something like this is what I've done:
  
  ```
  <td {$tdfirstStyle}>
  {* Truncate $line.label to hide a discount code if present for certain event types *}
  {if $event.event_type_id == 12}
    {if $line.html_type eq'Text'}
      {$line.label|truncate:7:"":false:false}
    {else}
      {$line.field_title} - {$line.label|truncate:7:"":false:false}
    {/if}
  {else}
    {if $line.html_type eq 'Text'}
      {$line.label}
    {else}
      {$line.field_title} - {$line.label}
    {/if}
  {/if}
  {if $line.description}
    <div>{$line.description|truncate:30:"..."}</div>
  {/if}
  </td>
  
  ```
  
  I think for this to work cleanly you might need to have Fee Levels with names of similar character count. There might be some other output filter that would work better than `truncate`... I recall trying to use some sort of RegEx filter that didn't work.
  
  
  ---
  
  