Answers.Body: <p>Also have a look at the answer to this more recent question about how to add custom Participant and Organisation fields to an invoice.</p>
  
  <p><a href="https://civicrm.stackexchange.com/questions/29230/how-to-create-tokens-for-custom-fields-participant-individual-organisation">How to create tokens for custom fields (participant, individual, organisation)</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-20T13:40:35.177Z
Answers.LastActivityDate: 2019-04-20T13:40:35.177Z
Answers.UserDisplayName: Davy Ivins
Answers.Body: <p>So, I remembered that there is such a thing as Smarty calls to the CiviCRM API.</p>
  
  <p>Stuck the following code into the template and bam! Got my custom field to show up in my generated invoice.</p>
  
  <pre><code>{crmAPI var='result' entity='Contribution' action='get' invoice_id="$invoice_id"}
  {foreach from=$result.values item=poid}
      {$poid.custom_40}
  {/foreach}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-16T00:32:43.967Z
Answers.Text: Does the custom field need to show up on the contribution form or payment recording form or does this work with any custom field? What does poid mean? My custom field has a gid and an id.
Answers.UserDisplayName: Christia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-15T16:28:45.413Z
Answers.LastActivityDate: 2015-09-15T16:28:45.413Z
Answers.UserDisplayName: Squishus Tyrannicus
Body: <p>I'd like to be able to display a custom field in the generated PDF invoice for a contribution. I've added the custom field to contributions, but it will not show up in the invoice.</p>
  
  <p>Is it possible to display this custom field on the invoice? If so, how?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-15T07:42:03.400Z
Comments.Text: Usually you use tokens for this and I think the token for a custom field is something like {contact.custom_nn} where nn is the ID of the custom field. If the custom field is from a contribution you might try {contribution.custom_nn} but not sure wether that works.
Comments.UserDisplayName: Jaap Jansma - CiviCooP
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-15T13:53:03.947Z
Comments.Text: Gave it a shot. No such luck.
  
  I spend some time digging around in the codebase. It looks to me as though the variables that are provided to the invoice template are provided in a static way, so that custom fields are not pushed to the template.
Comments.UserDisplayName: Squishus Tyrannicus
Tags: <civicontribute><invoice>
Title: How do I display a custom field in an invoice?
ThreadText: # How do I display a custom field in an invoice?
  
  (Asked by: username_0 on 2015-09-14)
  
  I'd like to be able to display a custom field in the generated PDF invoice for a contribution. I've added the custom field to contributions, but it will not show up in the invoice.
  
  Is it possible to display this custom field on the invoice? If so, how?
  
  **Tags:** civicontribute, invoice
  
  > **Comments:**
  > **username_1**: Usually you use tokens for this and I think the token for a custom field is something like {contact.custom_nn} where nn is the ID of the custom field. If the custom field is from a contribution you might try {contribution.custom_nn} but not sure wether that works.  
  > **username_0**: Gave it a shot. No such luck.  I spend some time digging around in the codebase. It looks to me as though the variables that are provided to the invoice template are provided in a static way, so that custom fields are not pushed to the template.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-09-15. Score: 9 | Accepted answer
  
  So, I remembered that there is such a thing as Smarty calls to the CiviCRM API.
  
  Stuck the following code into the template and bam! Got my custom field to show up in my generated invoice.
  
  ```
  {crmAPI var='result' entity='Contribution' action='get' invoice_id="$invoice_id"}
  {foreach from=$result.values item=poid}
      {$poid.custom_40}
  {/foreach}
  
  ```
  
  > **Comments:**
  > **username_3**: Does the custom field need to show up on the contribution form or payment recording form or does this work with any custom field? What does poid mean? My custom field has a gid and an id.  
  
  ---
  
  ### Answer by username_2 on 2019-04-20. Score: 1
  
  Also have a look at the answer to this more recent question about how to add custom Participant and Organisation fields to an invoice.
  
  [How to create tokens for custom fields (participant, individual, organisation)](https://civicrm.stackexchange.com/questions/29230/how-to-create-tokens-for-custom-fields-participant-individual-organisation)
  
  
  ---
  
  