Super-excessive number of price set fields in the Discount selection box, plus unhelpful ordering of price set items
Created by: bhugh
We have quite a lot of price sets & price set field accumulated over time. The CiviDiscount module shows EVERY price set & field ever entered, even if the price set is 'disabled'. After an event is over we can disable the price set, but generally we don't want to DELETE it entirely, as it is linked to the event registration page (which we also do not want to delete) because various event payments are linked to the event registration page.
Also, with so many price sets out there, listing them in order of price field label makes any individual price field almost impossible to locate.
So the solution to the above problems is pretty simple and can be made in Utils.php:
Around line 74, change this line:
$additionalWhere = 'ps.is_quick_config = 0';
To this:
$additionalWhere = 'ps.is_quick_config = 0 AND ps.is_active = 1';
That excludes any price sets that are set to INACTIVE.
About line 101, change this:
ORDER BY pf_label, pfv.price_field_id, pfv.weight
To this:
ORDER BY ps_label, pf_label, pfv.price_field_id, pfv.weight
This orders the price set fields by their price set name, meaning that it becomes easy to find all fields associated with a particular event or contribution page. Which is usually what you are doing when you want to set up a discount code.