Details
Description
I'm running Civi 4.4.5 on D6, but I think this is CMS-agnostic.
If you set up a price set for an event that contains a required fee level which is allowed to be 0, and also contains non-zero optional fee levels, and then set the required fee level to zero and select a non-zero optional fee, the javascript on the register form will hide the payment details fields, but the form won't submit without them.
For example, we're running a conference this summer, and we have some extra-fee events before the main conference. Sometimes our attendees can't make the full conference, but still want to come to the pre-conference workshops. So, we set up a price set to allow them to register for only the pre-conference events, but because it runs into the problem above, it isn't actually working.
I've reproduced the issue on the demo site; you can see it in the attached screenshots.
After a bit more research (and see https://issues.civicrm.org/jira/browse/CRM-14278) it looks like the problem is within the if statement on lines 217-218 of templates/CRM/Event/Form/Registration/Register.tpl
Problem lines:
if (((cj('#priceset input:checked').attr('data-amount') == 0) ||
cj('#pricevalue').text() == symbol + " 0.00" )) && flag) {
Fixed to:
if (cj('#pricevalue').text() == symbol + " 0.00") {
The "flag" value seems to be checking if multiple participants are enabled, but when I left it in the if statement the payment details would not hide, even when the price was 0 and no additional participants were selected. After removing it from the if statement, the form works fine, UNLESS someone signs up for multiple participants, but registers themselves for free. In that case, as soon as a participant is selected which costs money, submission will fail due to lack of payment details.
Not sure how to go about fixing that.