Cannot change membership price set on contribution pages
Overview
On the Membership tab of a Contribution page, a user cannot successfully change the Membership Price Set after the initial configuration of the page.
Reproduction steps
- Go to Memberships > Manage Price Sets -> Create two price sets, each for memberships
- Go to Contributions > Manage Contribution Pages -> Either create a new page, or if using a civibuild site you can use the pre-built Membership page
- Click on the Amounts tab -> make sure Contribution Amounts section enabled? is unchecked
- Click on the Memberships tab ->Set the Membership Price Set to your first Price Set
- Click Save
- Change the Membership Price Set to your second Price Set
- Click Save
- An error message will be displayed and the second price set will not have been saved as the selection:
Current behaviour
A user cannot switch the options for the Membership Price Set field, and instead get the follow error, despite that the Amounts tab is configured correctly (
You cannot enable both Membership Signup and a Contribution Price Set on the same online contribution page.
Expected behaviour
A user should be able to switch the options for the Membership Price Set without error.
Environment information
- CiviCRM: _Master/5.66.alpha1
Comments
This issue is being caused by a comparison value problem on line 249 in CRM/Member/Form/MembershipBlock.php. getFieldValue()
is returning a string padded with non printable characters, and the following if
statement is trying to compare that to a string without those additional characters, so the two values are determined to be unequal and this error is thrown.
I have a patch on GitHub to resolve this: #27030