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) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Advice on overloading a core method for my Tax field extension
Pages: [1]

Author Topic: Advice on overloading a core method for my Tax field extension  (Read 1449 times)

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Advice on overloading a core method for my Tax field extension
January 20, 2013, 04:40:40 pm
I'm working on an extension that provides the ability to apply taxes to specific contribution types.

We hacked civiCRM 3.4.x core to achieve this ability and our code works well but I'd like to make it modular and maintainable.   

Using the civix tool, I've sort of got the front end done so the admin can add/apply taxes to specific contribution types. It then adds tax related statements to applicable contribution pages but now I have to roll up my sleeves to do some real work; namely overloading the public function preProcess() that can be found in civicrm/CRM/Contribute/Form/Contribution/Confirm.php and civicrm/CRM/Event/Form/Registration/Confirm.php.

I'd like my extension code to use hook_civicrm_buildForm($formName, $form) test the contribution type and if it's applicable, query my tax tables to see which taxes are applicable, calculate the tax, stuff the values in a civi_tax_invoicing database table that I'll add to the detailed report.

The first thing I need some direction on is how can I overload the preProcess() function.

Once I've got that working, I'll be back looking for direction on overloading the reporting functions. When we hacked core to make this work on 3.x we found that the lions share of the work was involved in the reporting side so I am prepared for some late nights and frustration getting this completed  :'(

Thanks,
Andrew
My CiviCRM Extension Workshop: https://github.com/awasson

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: Advice on overloading a core method for my Tax field extension
January 21, 2013, 03:12:55 pm

the preProcess and buildForm function are called sequentially (so for all practical purposes, u can think of them as one function)

any specific reason u cannot put all your custom code in your buildForm hook

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

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: Advice on overloading a core method for my Tax field extension
January 21, 2013, 08:29:53 pm
Hey Lobo,

Thanks for the direction.

I was thinking that I could add my code in the buildform hook but I'm not sure how. With the hack we performed we added the code smack dab in the middle of the preProcess function. Can I declare the function in my extension so that it will take precidence over the OEM function. If so is there some documentation about how the naming convention is handled?

Thanks,
Andrew
My CiviCRM Extension Workshop: https://github.com/awasson

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: Advice on overloading a core method for my Tax field extension
January 22, 2013, 07:14:32 am

andrew:

r u changing the current preProcess function or just adding code to it? if the latter, u can do it in your buildForm hook

there is no convention so far on over-riding the preProcess function. Might want to jump on irc and chat with us regarding this

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) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Advice on overloading a core method for my Tax field extension

This forum was archived on 2017-11-26.