Being able to group Thank You Letters by contact is a great feature for both everyday receipts (we have a company that will donate via multiple smaller donations at once) and end of the year receipts.
But I'm running into a problem, if I use an if statement around a contribution token, the token no longer loops for each contribution printed. For example:
{crmAPI var='contresult' entity='Contribution' action='get' sequential=0 id=$note_id}
{foreach from=$contresult.values item=contribution}
{if $contribution.non_deductible_amount gt 0}${$contribution.non_deductible_amount}{else}N/A{/if}
{/foreach}
The function doesn't display anything when I 'group by' (If I run a thank you letter for a single contribution it does work.)
In this example:
{capture assign='note_id'}{contribution.contribution_id}{/capture}
{crmAPI var='result' entity='Note' action='get' sequential=0 entity_table="civicrm_contribution" entity_id=$note_id}
{assign var='note_count' value=$result.count}
{if !$note_count}None{elseif $note_count}
{foreach from=$result.values item=note}{$note.note}{/foreach}
{/if}
It only returns "None" once, when the contributions all have notes.
How can I make the if statement run for each of the contributions selected for the thank you letter?