CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Getting Contribution Receipts To Show Only the Custom Fields I Want
Pages: [1]

Author Topic: Getting Contribution Receipts To Show Only the Custom Fields I Want  (Read 1524 times)

zkrebs

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 1
Getting Contribution Receipts To Show Only the Custom Fields I Want
February 03, 2012, 09:21:32 am
Right now the behavior is contribution receipts show all attached custom data sets for my contributions in the receipt. Some I do not want the customer to see!

It was suggested in IRC that I could easily update the templates if I knew PHP / Smarty, but apparently I know less than I thought. Please assist me!

I would like to either show every field in a custom data set (attached to a contribution) - on a case-by-case basic. include sets 1,2, but not 4.

Or, just know how to show specific fields, and remove the functionality that shows all sets by default.

Thank you for your help and patience. If someone wouldn't mind showing me an example, I could learn how to do it.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Getting Contribution Receipts To Show Only the Custom Fields I Want
February 07, 2012, 03:26:59 pm
I assume you're talking about offline contribution receipts (since the online receipts only expose fields you've included in a profile in the online contribution form).

The logic you'll need to play with is contained in the System Workflow Message Template for "Contributions - Receipt (off-line)"

The default smarty code is:

Code: [Select]
{if $customGroup}
{foreach from=$customGroup item=value key=customName}
===========================================================
{$customName}
===========================================================
{foreach from=$value item=v key=n}
{$n}: {$v}
{/foreach}
{/foreach}

You'll need to modify / replace that first foreach statement so it just gets the custom groups you want to include. If you have a test environment and can turn on debugging, then add {debug} tag in this message template and it will spit out all the smarty variables assigned to the template - which will help you filter out the elements in $customGroup array.

HTH
« Last Edit: February 09, 2012, 03:28:31 am by michaelmcandrew »
Protect your investment in CiviCRM by  becoming a Member!

fmcooke

  • I’m new here
  • *
  • Posts: 18
  • Karma: 2
    • Beta Consulting
  • CiviCRM version: 4.3.5
  • CMS version: Joomla! 2.5.13
  • MySQL version: N/A
  • PHP version: PHP Version 5.3.10-1ubuntu3.1
Re: Getting Contribution Receipts To Show Only the Custom Fields I Want
September 07, 2013, 08:12:31 pm
It can be done with:

    {if $customGroup}
      {foreach from=$customGroup item=value key=customName}
       {foreach from=$value item=v key=n}
          {if $n eq 'Field Name that you like to use'}
                     {$n}: {$v}
          {/if}
       {/foreach}
      {/foreach}
     {/if}

Another usefull thing I found (Sorry if it is too obious) is that you can place withing the message the statment:

{php}

        exit();

{/php}

</body>
</html>

At the end of the form and you will see the message without sending an email (At least this worked for mailing contribution receipts)


Kind regards,
Federico

Kind Regards,
Federico Cooke

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Getting Contribution Receipts To Show Only the Custom Fields I Want

This forum was archived on 2017-11-26.