Refactor display of price sets and allow backend registration changes for sold out price set items #26112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This replaces #24639 — as that one was old, so I'm bumping this back up. The can't remove people from full price set options bug has been a real pain for us in the past and I'm sure we aren't the only ones, so hopefully we can get this merged. The refactor also allows for some additional work that I've already done that will optionally show how many spaces are remaining in each option - something that has caused a lot of frustration for people trying to register a group of four for workshops with limited space (will post a PR for that once this one has been merged).
The most important change here is some refactoring of the very repetitive Quickform code for price sets to make that a little more maintainable (though there still a lot more that could be done).
Additionally, when editing price set selections for an event registrant, you cannot add or remove sold out items. This PR makes it possible for backend users to add or remove price set selections that are sold out from registrations. It also ensures that all full selections show (Sold out) text, both on the Register Participant form and the Change Selections and Edit Event Registration forms.
It also fixes some inconsistent fonts, margins, spacing, etc in price sets.
Before
Each of four types of price field was generated through a separate block of code, with a lot of repetition, making it hard to maintain.
If a price set selection is sold out, back-end users can add this selection on Events - Register Event Participant, but if they edit a existing registration they cannot either add or subtract from sold out selections as these are disabled/frozen (except for removing select fields, which was possible). Back-end users may add registrants to sold out selections unintentionally, as there is no warning that selections are sold out on the Register Participant Form. Backend users cannot remove registrants from sold out selections, which should clearly be possible. They cannot override price set limits if required to add participants to sold out selections.
Register Participant: Backend user can register participant for sold out selections, they are unmarked
Change Selections: Participant cannot be added or removed from sold out selections
Front end registration, lots of odd styling
After
A good chunk of the price set logic has been broken out into a separate function, allowing re-use in each type of price field, cutting down on repeated code.
Backend users can register and deregister participants for any price set selection. All price set selections that are sold out are now marked as sold out.
Register participant: Sold out selections are now marked
Change Selections: Participant can be added to or removed from all selections.
Front end registration, a little more readable and consistent
I've also removed the italics, font size and weight from sold out items so the form is less busy and more consistent, enclosed the none option in a span to match other radio options, and added the light sold out grey colour to all sold out options (except the select options). I removed the double 'Sold out' for text fields and added the missing 'Sold out' on select options. Added space between frozen checkbox and radios and text. Fixed inconsistent font size and spacing for pre and post field help.
Comments
I've also aligned the process for Text fields with the process for all the other types by moving this from the tpl to the Price Field BAO, so it can use the same function rather than implementing the same logic in Smarty. This required a small change that is a bit odd to get the label for the text field to the tpl, introducing an auxiliary form element that holds the label that goes after the text field, since the text field has two labels. This is all working around the unfortunate situation where text fields are both price fields and price options at the same time.
I've removed some now unneeded code that set form rules for selects and some other repeated code.