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) »
  • custom field needs to be used in total price in contribute, how?
Pages: [1]

Author Topic: custom field needs to be used in total price in contribute, how?  (Read 2876 times)

webguy2

  • Guest
custom field needs to be used in total price in contribute, how?
October 07, 2008, 08:29:12 am
I'm comfortable with PHP and I added a custom field (how many apartments are managed) to the civicontribute membership page.  In processing the total price for the next page, I need to use the number in that custom field to help calculate the total price.  Each apartment managed adds $2 to the total cost/price on top of the membership fee selected.

I need to catch it between This URL:
/civicrm/contribute/transact?reset=1&action=preview&id=2

And this URL:
/civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=0f17208586980049f47959cb1f89ed7b

The custom field I need to get and custom calculate is:
<input name="custom_6" type="text" value="0" id="custom_6" class="form-text required" />

I need to combine a calculation of the custom field and add the membership fee selected before it gets to, transact?_qf_Confirm_display, page.

Which civicrm php file do I need to customize to do this? I believe this takes place in the civicrm/CRM/Contribute/Form/Contribution/Main.php page.

Any ideas are welcome!  Thanks in advance!!

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: custom field needs to be used in total price in contribute, how?
October 07, 2008, 08:41:38 am

1. Please do not ask the same question in multiple places (i deleted your question in the civicontribute forum)

2. CRM/Contribute/Form/Contribution/Main.php, function computeAmount

i think (and hope) that this is the only place you need to modify to determine the amount that will be charged

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

webguy2

  • Guest
Re: custom field needs to be used in total price in contribute, how?
October 07, 2008, 09:16:37 am
Thanks and sorry for the double posting.  I saw the developers forum after posting elsewhere.

Regarding the compute total, how do I get a handle to the custom_6 custom field?

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: custom field needs to be used in total price in contribute, how?
October 07, 2008, 09:20:35 am

$params['custom_6']

should give you the value submitted for custom_6

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

webguy2

  • Guest
Re: custom field needs to be used in total price in contribute, how?
October 07, 2008, 10:02:18 am
don - thanks, it works well!

One other quick related question, I only want this calculation to be in effect for member and renewals.  What param do I need to check for?

(Without Devel module working on civicrm, I can't see as much as I can on other pages so your help is greatly appreciated!)

It's contribution id = 5

Again, many thanks!!
« Last Edit: October 07, 2008, 10:09:42 am by webguy2 »

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: custom field needs to be used in total price in contribute, how?
October 07, 2008, 10:57:02 am

In that function, $self->_id will give you the contribution page id

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

webguy2

  • Guest
Re: custom field needs to be used in total price in contribute, how?
October 07, 2008, 12:17:20 pm
you guys rock - many thanks!

mariagwyn

  • I post frequently
  • ***
  • Posts: 149
  • Karma: 4
  • CiviCRM version: CiviCRM 3.3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.2.14
  • PHP version: 5.0.91-50-log
Re: custom field needs to be used in total price in contribute, how?
October 13, 2009, 10:50:21 am
webguy....

I need to calculate a custom field as well.  any chance you would be willing to share your .tpl file?  I don't write php, but I modify other's.  I know, I should learn...

Thanks!

m

mariagwyn

  • I post frequently
  • ***
  • Posts: 149
  • Karma: 4
  • CiviCRM version: CiviCRM 3.3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.2.14
  • PHP version: 5.0.91-50-log
Re: custom field needs to be used in total price in contribute, how?
October 22, 2009, 01:16:33 pm
Can this recalculation happen at a tpl level rather than in a core php file?  I want to recalculate all credit card payments to add a 5% charge and am not sure where to do it.

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: custom field needs to be used in total price in contribute, how?
October 22, 2009, 02:05:35 pm

i dont think so.

i'm not very sure how u'll do it. Potentially in the hook_civicrm_buildAmount if the user has chosen to pay by credit card. i.e u'll need to examine the form and see what the user has chosen, so in the confirm page it shows the right amount with the 5% surcharge

let us know if that works

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) »
  • custom field needs to be used in total price in contribute, how?

This forum was archived on 2017-11-26.