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) »
  • Where does price set structure come from?
Pages: [1]

Author Topic: Where does price set structure come from?  (Read 1315 times)

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Where does price set structure come from?
September 11, 2010, 06:24:44 pm
I am working on a module to provide permissions settings for price set options. The idea is that you can select groups that have access to specific price set options. As part of the process I also created a price set hook similar to the buildAmount hook (with much help from Lobo).

My hook is in CRM/Price/BAO/Set.php at the end of getSetDetail and is being called as expected.

I am modifying the price set structure and removing any of the price options that are not accessible to the current registrant. Using XDebug I can see that the option is removed from the structure, but when the form renders, it still shows the option. I've stepped through the code and haven't found any other location where the price set is modified.

I cleared the drupal cache, removed cached docs in templates_c, cleared the browser cache and recreated the price set just to be safe.

Is there another place in the code that I should place this hook? I assume I am overlooking another location where the structure is setup, or a different structure is being used to build the form and I am missing it completely.

Thanks for your help,
Quint

Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

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: Where does price set structure come from?
September 12, 2010, 08:51:13 pm

can you post your patch. we'll apply it and take a look at whats happenign and why

thanx

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

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Where does price set structure come from?
September 13, 2010, 01:33:43 pm
Hi Lobo,

Patch files are attached.

Thanks for taking a look.

Quint
Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Where does price set structure come from?
September 17, 2010, 02:53:21 am
OK - I think I've got it. Even though it looks like there is a nice price set structure used to build the form, that isn't really the case. When the actual form is built, the field id is passed to CRM/Price/BAO/Field.php::addQuickFormElement. That function ends up getting the price field options directly from the db using getOptions.

Now that I understand what is happening, I am a little confused. It seems like there is a lot of work and copying going on to build a structure that never really gets used. We end up with $priceSet and $form->_values, both of which have a copy of the price set structure. $form->_values gets used once, just to get the individual field ids and start the price set form, but the rest of the structure appears to be unused. Then, after we already have 2 copies of the price set structure, we go and ask for all of the price field options one more time, just to be sure, in the addQuickFormElement function.

I think I may have to rewrite my hook as a price option hook instead of a price set hook, since there doesn't appear to be a price set structure to modify like there is with the buildAmount hook.

I am relatively new to digging around the internals of CiviCRM so if any part of this is wrong I claim safe haven in my newbie status :)

Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Where does price set structure come from?

This forum was archived on 2017-11-26.