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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Add billing address + custom contribution fields to offline membership receipt
Pages: [1]

Author Topic: Add billing address + custom contribution fields to offline membership receipt  (Read 1095 times)

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Add billing address + custom contribution fields to offline membership receipt
July 04, 2013, 09:45:50 am
I would like to add the billing address and some custom contribution fields to the offline membership receipt. The billing address is already in the template but only set if $form->_mode is set.

I am trying to inject this info in the postProcess hook (if $formName ==  'CRM_Member_Form_Membership') at the moment.

I have changed the smarty template for the message to include html and placeholder tokens for these.

As far as I can tell the flow goes through CRM/Member/Form/Membership.php calling emailReceipt, which calls CRM_Core_BAO_MessageTemplates::sendTemplate.

It looks from that like the only other place I can use is the hook tokenValues. However by the time I get there I will lose the custom data I have access to in the postProcess hook - unless I store the data in a global variable perhaps?

Any suggestions?
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Add billing address + custom contribution fields to offline membership receipt
July 04, 2013, 02:46:23 pm
Or slightly better than a global you can stash in a singleton function e.g

my_civicrmPostProcess($form){
if blah blah
my_singleton($valueToStash);
}

my_singleton($value){
 static $stashedVar;
if(empty($value){
return $stashedVar;
else{
$stashedVar = $value;
}
}
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Re: Add billing address + custom contribution fields to offline membership receipt
July 04, 2013, 03:11:57 pm
Eileen,

Thanks, that is an improvement.
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Re: Add billing address + custom contribution fields to offline membership receipt
July 10, 2013, 07:42:47 am
I'm just getting back to this and found another more serious problem. The tokens hook is called before postProcess so that don't have time to save my custom data in a singleton function or global variable. Does this sound like something that should be fixed?
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Add billing address + custom contribution fields to offline membership receipt

This forum was archived on 2017-11-26.