7

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?

  • 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. – Jaap Jansma - CiviCooP Sep 15 '15 at 7:42
  • 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. – Squishus Tyrannicus Sep 15 '15 at 13:53
9

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}
  • 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. – Christia Jan 16 at 0:32
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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.