4

I'm supposed to change the message template used when you wanna make a PDF receipt of a contribution. I found the template and started to modify its HTML code, unfortunately I'm not able to display the payment vehicle (cash, check,...). I tested a few tokens ({$payment_instrument} for instance) found on the internet but it didn't work. And I don't really know where I'm supposed to find all of the tokens (yes, I'm a bit of a beginner...).

Thanks !

2 Answers 2

6

I think you can use Smarty to retrieve the payment instrument in your template. You can play with API explorer to return this value -

enter image description here

Copy the contents in smarty section and add it to your template. Eg -

{crmAPI var='result' entity='Contribution' action='get' id=<contribution_id_variable>}
{foreach from=$result.values item=contribution}
  {$contribution.payment_instrument}
{/foreach}

In the above statement $contribution.payment_instrument should hold a value of the payment vehicle.

1
  • Thank you for your answer. Unfortunately, we weren't able to make your code works. So finally we decided to use the "Thank-you letters - print or email" functionality to be able to access easily to the tokens needed (by using the combobox in the template).
    – Davum
    Commented Feb 28, 2019 at 8:50
1

you don't have a straight forward option at the moment (I guess)

Civicrm by default picks only contact Token

In-order to display payment method in the Invoice you need to create a new extension which can select the contribution payment method (as a token)

Ref Link:

https://docs.civicrm.org/dev/en/latest/hooks/

https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/

I guess this helps !!!

If you need more help - please let me know

Thanks

2
  • Not sure if this is the correct answer. The Invoice Template is a System Message and system messages are smarty templates. So one could use the API in the message template to retrieve additional data. It is quite complex but it is doable. Commented Feb 21, 2019 at 16:08
  • @JaapJansma-CiviCooP - If you create a token_hook it will work - But That token will work only when you print/Email Invoice - This above solution is achievable Commented Feb 22, 2019 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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