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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook_civicrm_buildAmount Doesn't Appear to be Called
Pages: [1]

Author Topic: hook_civicrm_buildAmount Doesn't Appear to be Called  (Read 1726 times)

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
hook_civicrm_buildAmount Doesn't Appear to be Called
December 27, 2009, 12:53:44 pm
I am working in Drupal 6 Civi 3.0.2 and while hook_civicrm_buildForm works fine I don't see hook_civicrm_buildAmount being called when I visit an event registration page.

I am trying to build a feature akin to the "Event discounts / coupons for event registration" post: http://civicrm.org/node/566 but it requires that hook.

If it indeed is not working, then I will use hook_civicrm_buildForm and attempt to manually adjust the prices.

I furthermore, however, need to account for PayPal as the payment processor, in the offsite mode. Clearly when one clicks on the PayPal button, the request goes to CiviCRM and then the user is redirected to paypal.com. So ideally I would want to hook into that process and examine the discount code and then actually do one of two things:

1. If it's valid, then make the price zero, as these coupons are for 100% off. In that case, the user wouldn't need to go to PayPal at all.

2. If it's invalid, I think the best would be to return the user to the page to allow him the opportunity to re-enter his code.

It may be easier to simply add a form on the event info page--the user can then enter his discount code there and then all processing can be handled by hook_civicrm_buildForm.

Any feedback on this is appreciated.

Thanks.
« Last Edit: December 27, 2009, 01:15:15 pm by hershel »
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: hook_civicrm_buildAmount Doesn't Appear to be Called
December 28, 2009, 03:59:07 am
Are you using price-sets ? since the buildAmount() hook doesn't work for price-sets.

Quote
1. If it's valid, then make the price zero, as these coupons are for 100% off. In that case, the user wouldn't need to go to PayPal at all.
If you can adjust / make price to zero (via discounting method or any other), civicrm would take care of that.

Quote
It may be easier to simply add a form on the event info page--the user can then enter his discount code there and then all processing can be handled by hook_civicrm_buildForm.
Event Info page is a CRM_Core_Page, and doesn't support adding Form elements. You could create your own customised Form (using custom php and templates ) and work that way.

Quote
2. If it's invalid, I think the best would be to return the user to the page to allow him the opportunity to re-enter his code.
Validation and redirecting / bouncing to above page should be possible via hook.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: hook_civicrm_buildAmount Doesn't Appear to be Called
December 28, 2009, 12:12:28 pm
Quote from: Deepak Srivastava on December 28, 2009, 03:59:07 am
Are you using price-sets ? since the buildAmount() hook doesn't work for price-sets.

That was it. Without price sets, it works fine.

Quote from: Deepak Srivastava on December 28, 2009, 03:59:07 am

If you can adjust / make price to zero (via discounting method or any other), civicrm would take care of that.

Yes, this also works perfectly. Thank you.

However, the issue now is that the discount awarded is 100%, but the site requires the user to enter his credit card number to proceed. On the following page, he is not charged anything because the amount has been reduced to zero, but he can't get there without entering a CC number.

Seems to be a bit of a quandary...
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

alfred_nutile

  • Ask me questions
  • ****
  • Posts: 464
  • Karma: 14
    • River Valley Tech Collective
Re: hook_civicrm_buildAmount Doesn't Appear to be Called
January 28, 2010, 08:02:15 am
I would like to change the template for this ONE form to make -none- say 'Not Now' for example.
Knowing civicrm's template process what file would I move into the template folder to hook this text.
Thanks

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook_civicrm_buildAmount Doesn't Appear to be Called

This forum was archived on 2017-11-26.