Closed (fixed)
Project:
CiviEvent Discount
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
28 Dec 2011 at 11:00 UTC
Updated:
24 Jan 2012 at 14:40 UTC
Jump to comment: Most recent file
Comments
Comment #1
dharmatech commented@jeevajoy, thanks for reporting this. Are you using the "automatic discount" for members and expecting that additional participants would not be allowed to use the discount?
Comment #2
dharmatech commentedComment #3
jeevajoy commentedwhat i tried was Registering for an event. I generate the code for particular membership type ex. \student in the civievent discount module.
While registering i tried to get the email and via api i check whether he is active member or not and his membership type. If he is active member then i'll pass the discount code where it sets the Discount.
I used Buildform hook.
The problem is when i register the additional participants also gets the discounted fees as event fees. I need to check whether the additional participants also a active member and then only i should pass the discount code.
Hope you understand this.
Comment #4
dharmatech commentedHow are you "get the email and via api I check whether he is active member?" Are you writing another module that ties in with the discount module or just hacking it?
If you're just hacking it, how about generating a patch?
If you're writing another module, sorry, you're on your own.
Currently, it does not check if additional participants are members. It would be great if you could supply a patch that checks for that. It might be very difficult to implement via Civi provided hooks. You'll need to see if hook_civicrm_buildAmount() allows you access to additional participants page and then do a lookup if the additional participant is a member. You obviously won't be able to do that until after the form has been submitted. Not trivial.
This is a problem w/additional participants in general and not directly related to memberships.
Don't adjust priority, status, etc. unless you plan to take ownership of the ticket and supply a patch.
Comment #5
jeevajoy commentedi'm just extending this module. Just getting the email and checking the membership. I've almost complete but one problem when i go to additional particpant page in event registration it gets the discounted amount instead of the original amount.
I'll update the patch tomorrow and hope that gives better idea to you.
sorry for adjusting the priority. i thought it was mandatory.
Comment #6
jeevajoy commentedHi,
I've added the patch file. In the patch file I tried to get the user email address and check whether he is a active member and pass the discount code as hidden.
It works fine for the Main participant.
Need suggestions to how to make it work for additonal particpants.Currently if main participants gets discount then the additonal participant also gets the same discount.
Awaiting your reply.
Comment #7
dharmatech commentedI really appreciate you taking the time to work on this, but quite honestly it still needs a lot of work. After a brief code review, here's a list of problems that standout:
Something to consider, we need a way to enable/disable this functionality. There is a use case for allowing a member to signup additional participants and passing that discount on to them. We have a checkbox at admin/settings/civievent_discount/settings that allows for multiple participants but we aren't really using it anywhere. Perhaps we give two options:
Comment #8
jeevajoy commentedThanks for your reply.I'm still working on it.
Is it possible to disable the discount for additional participants when
allow multiple participants is not checked?
Comment #9
dharmatech commentedShould be possible in the buildAmount() hook. You'll need to find a unique key/value in $form we can use that indicates we're in the additional participants screens. If you var_dump($form) you should be able to find something.
Comment #10
jeevajoy commentedthanks will find a way.
Comment #11
dharmatech commented@jeevajoy, any luck making the modifications? If you get stuck and need help, let me know.
Comment #12
jeevajoy commentedsorry i got stuck. Dont know how to check addtional participant page in buildAmount hook.
Comment #13
dharmatech commented$form is an object passed into buildAmount(). If you compare $form when the first participant registers vs. when additional participants register, you should find a unique key. It might be the form name or possibly a key/value pair indicating which additional participant we're on.
I recommend using xdebug w/an interactive debugger. If you don't want to do that, just whatever flavor of var_dump/print_r/dpm you like to compare $form values.
Comment #14
dharmatech commented@jeevajoy, were you able to find that $fname == 'CRM_Event_Form_Registration_AdditionalParticipant' in buildAmount()? There's an _allow_multiple() that will tell you whether the discount settings allow multiple participants. That should be all you need.
Comment #15
dharmatech commentedFixed in latest -dev release. You may need to wait 24 hours for the update to appear. This has not been fully tested but the "happy path" appears to work perfectly.
The settings page and description has been cleaned up and delicate nature of form processing in buildAmount() has been reworked. This hopefully addresses the broken and ambiguous use of additional participants discounts. There are only two options now: