Discount gets applied to all price options if there is more than 1 price field with options, and the number of options selected from the first field on a discount is equal or greater than 50% of the total number of options
When trying to limit a discount to specific price fields, since updating to CiviDiscount 3.8.7 (2022-11-28), the discount applies to all price fields under certain conditions. I am not positive the title is correct, but after many tests the issue can be replicated by following these steps (I have tested on multiple sites):
- Create a price set
- Create a price field (P1), type radio with 2 options
- Create a second price field (P2), also type radio with 2 options
- Create an event selecting your new price set under the fees tab
- Create a new discount code that is limited to the 2 price options from P1 and the event you created. (It does not matter if you select an automatic option or require the use of the code, you should see the same result)
- Visit your event form, you will see that the discount gets applied to all options in P1 AND P2 instead of only P1
If you then add a new option to either price field without modifying the discount and refresh the form, the discount will correctly only apply to the first 2 price options you had set on the discount. But, if you add another option to P1 and add that option to the discount, the form will go back to applying the discount to all options, including those in P2 again.
I was not able to recreate a problem using only a single price field, nor am I able to replicate it by selecting all of the options from P2 rather than P1 on the discount - the issue appears to be limited to only when the number of options selected from the first price field is half or more of the total number of options.