Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-17396

Editing a membership price set breaks auto-renew functionality

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.4.19, 4.7
    • Fix Version/s: 4.7
    • Component/s: CiviMember
    • Labels:
    • Documentation Required?:
      None
    • Funding Source:
      Core Team Funds

      Description

      I replicated this bug in 4.4 and also in master. I've tracked down the cause but don't have funding to pursue a complete fix; however, if someone else comes across this error, this should get them most of the way there.

      CRM_Price_BAO_Pricefield::addQuickFormElement is responsible for building the widgets that display on a contribution page. In particular, there's this block of code:
      {{
      if (!empty($qf->_quickConfig) && $field->name == 'contribution_amount')

      { $extra += array('onclick' => 'clearAmountOther();'); }

      elseif (!empty($qf->_quickConfig) && $field->name == 'membership_amount') {
      $extra += array(
      'onclick' => "return showHideAutoRenew({$opt['membership_type_id']});",
      'membership-type' => $opt['membership_type_id'],
      );
      }}

      When creating a "quick config" price set, the price field's name ("$field->name" above) is automatically set to "membership_amount" or "contribution_amount", and this code block works correctly.

      The bug occurs when a price set is converted from "quick config" to a standard price set and the price field is edited. On save, the "name" field of the price field is changed to match the label - which by default is "Membership". This causes the code block above to not add the "showHideAutoRenew" JS to the field. Presumably, this bug also means that changing a contribution price field breaks the "clearAmountOther" functionality as well.

      I believe the correct solution is to not set the name equal to the label on save. The appropriate function is (I believe) CRM_Price_Page_Field::edit, but since this is instantiating an object of type CRM_Core_Controller_Simple, I haven't the funding to track down the appropriate approach to fix this.

        Attachments

          Activity

            People

            • Assignee:
              monish.deb Monish Deb
              Reporter:
              palantejon Jon K Goldberg
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: