We have a need to display price field information in a contribution Thank You letter. As the token system can't handle the price set data, I've pulled the relevant Smarty code from the receipt template, which very nicely presents all of the price fields that were selected for the contribution.

Of course when I make PDFs, its not working : )

I have Smarty enabled for email in the settings.php, and I can use Smarty logic to display content in the Thank You - so Smarty is actually working. But the beginning loop "{foreach from=$lineItem item=value key=priceset}" seems to return nothing and thus no price fields are added to the letter.

Is this possible to do? What is needed to activate processing of price fields in a letter?

  • I'll add that I took all the code from the contribution receipt and dropped it into a Thank You letter, just as a test of my code. The result is a blank page. Feb 10, 2016 at 20:08

1 Answer 1


It doesn't work because $lineItem is not set in the template, you'll have to loop thorough $contribtuions and use the API:

{foreach from=$contributions item=contribution}
{crmAPI var='result' entity='LineItem' action='get' contribution_id=$contribution.id} 
  {foreach from=$result.values item=lineitem} 
    {$lineitem.label} // Price field label

Please note: this works fine generating ThankYou's with one contribution per individual.

Related topics for more details:

Let me know if that helps.

  • This is it, thanks! I'll just add for others that once the line item is loaded into the array $lineitem then its easy to access all the elements of the price field (or columns in the database table civicrm_line_item). $lineitem.label is the label, $lineitem.qty is the quantity, etc. Feb 13, 2016 at 20:45
  • Glad it help Eliot, if the answer is correct perhaps you could mark it answered, other people might find it useful.
    – Andrei
    Feb 15, 2016 at 20:41

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.