4

I want to use in a Mosaico template a token for the contribution and I found in a system template this string: {$totalAmount|crmMoney}.

I tried to use it in my new template but it doesn't show in the email. I have the civitoken extension but {latestcurrentmembership.allfee} doesn't show because it's a "pay later" option and I guess this token works only when the membership is already paid.

Any idea?

5

There are multiple "token" systems in CiviCRM depending on your context.

{$totalAmount|crmMoney} is a Smarty token, which only works in Smarty emails. System Workflow messages are Smarty, traditional templates don't handle Smarty by default, but can; Mosaico templates don't support Smarty (by design).

None of the approaches suggested above are without issues, but let's discuss them in turn.

  • {latestcurrentmembership.allfee} in Civitoken does NOT return the membership fee paid. It returns the "minimum fee" for the membership type (see screenshot): enter image description here

If all of your memberships of a particular type are always the same cost, you can set the "minimum fee" and use this token to solve your problem.

  • Even if you were using Smarty with your mailing, {$totalAmount|crmMoney} wouldn't be available as an option to you. Mosaico mailings are sent to contacts, not to contributions; the "total amount" token wouldn't know which payment you were referring to. Consider if instead you can use Thank-you emails or Scheduled Reminders or CiviRules instead of CiviMail. There's the mosaicomsgtpl extension that copies a Mosaico template to a traditional one for use with non-CiviMail mailings.

  • When sending as a contact, you CAN use a token for "Total amount of latest completed contribution". It's available in CiviToken, and depending on your situation, may solve your issue - but only considers completed contributions. To change this, open the civitoken folder, go to tokens/latestcontribs.inc, and remove the line that reads AND civicrm_contribution.contribution_status_id = 1 to consider all contributions, complete or not.

Finally, some solutions that don't (yet) exist:

  • The "Latest Membership Fee" token in CiviToken CAN return the actual amount - the author just didn't need to in her case, so she wrote a shortcut. One could create such a token.
  • I've got a task on my plate (probably for this month) to write tokens for contributions that can be filtered on financial type. So instead of "Total amount of latest completed contribution" you can specify "Total amount of latest completed contribution with Financial Type of 'X'". If this would solve your problem, let me know on https://chat.civicrm.org and I'll let you know when I get to it.
| improve this answer | |
  • Hi Jon G. What an answer! Thank you so much to have taken the time to write it. I now much better understand the context and how to get my situation work. I'm also interested in your tokens. – Guillaume Sorel Jan 10 at 11:12

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.