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) »
  • Getting values on contribution thank you pages
Pages: [1]

Author Topic: Getting values on contribution thank you pages  (Read 736 times)

xcf33

  • I post frequently
  • ***
  • Posts: 181
  • Karma: 7
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.19/6.20
  • MySQL version: 5.x
  • PHP version: 5.2.6
Getting values on contribution thank you pages
June 30, 2010, 10:56:57 am
Hi all,

I'm currently trying to incorporate google eCommerce conversion tracking code into CiviCRM contribution pages using Drupal API, I'm trying to implement a hook so I can retrieve the values that are displayed on the thank you page.

More specifically, I'm trying to grab the transaction id and contribution amount.

Looking at the thank you page I noticed that it is not a page rather than a form, therefore I decided to use hook_civicrm_buildForm, and indeed you can add javascript to the thank you page using the hook. However, I tried to access the values sent to smarty and got no result. I dumped the whole $form object and got over 70,000 lines and nothing I needed.

I also tried to read the quick form documentation and attempted to use methods such as

$form->getSubmitValues() ;
$form->getSubmitValue('amount');
$form->getElementValue('amount');

etc and I got nothing.



I'm now wondering that if those values on the thank you page are form elements after all, or there's just no way to access them via a hook


Thanks,


Chang
 

xcf33

  • I post frequently
  • ***
  • Posts: 181
  • Karma: 7
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.19/6.20
  • MySQL version: 5.x
  • PHP version: 5.2.6
Re: Getting values on contribution thank you pages
June 30, 2010, 02:45:03 pm
Quote from: Donald Lobo

$smarty  =& CRM_Core_Smarty::singleton( );
$smartyValues =& $smarty->get_template_vars( );
 

It works,

The second method returns a big array with all the variables sent to the smarty template engine.


Thanks lobo!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Getting values on contribution thank you pages
June 30, 2010, 10:30:25 pm

u can also use:

Code: [Select]
$smartyValue = $smarty->get_template_vars( 'NAME OF A SPECIFIC VARIABLE' );

which is probably a lot more efficient

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Getting values on contribution thank you pages

This forum was archived on 2017-11-26.