Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAE-492: Fix membership end date after CiviCRM 5.35 update #368

Conversation

ahed-compucorp
Copy link
Contributor

Overview

After updating to CiviCRM 5.35, If we created a payment plan membership with pending status, we found out that the end date will increase each time we recorded a new payment.

Before

Recording a new payment will increase the membership end date.
Peek 2021-03-12 21-12

After

Recording a new payment will not increase the membership end date.
Peek 2021-03-12 20-47

Technical Details

This PR civicrm/civicrm-core#18410 to CiviCRM core has the following change :

- $prevnext[] = $this->createElement('submit', $buttonName, $button['name'], $attrs);
+ $attrs['type'] = 'submit';
+ $prevnext[] = $this->createElement('xbutton', $buttonName, $button['name'], $attrs);

Instead of creating a button with the value "Record Payment" like this

<input class="crm-form-submit default validate" onclick="return verify( );" crm-icon="fa-check" name="_qf_AdditionalPayment_upload" value="Record Payment" type="submit" id="_qf_AdditionalPayment_upload">

It will create a button with the value "1" like this

<button class="crm-form-submit default validate crm-button crm-button-type-upload crm-button_qf_AdditionalPayment_upload" onclick="return verify( );" value="1" type="submit" name="_qf_AdditionalPayment_upload" id="_qf_AdditionalPayment_upload"><i aria-hidden="true" class="crm-i fa-check"></i> Record Payment</button>

And the condition here will be false

$isRecordPayment = CRM_Utils_Request::retrieve('_qf_AdditionalPayment_upload', 'String') === 'Record Payment';

The main point is to figure out if the submitted form is a record payment submission or refund submission and we can do that by checking the the variable _paymentType in the AdditionalPayment Form class and prepare it for MembershipEdit class.

Comments

Another potential solution is to alter the button attributes and inject the value "Record Payment" again like this

/**
 * Implements hook_civicrm_buildForm().
 */
function membershipextras_civicrm_buildForm($formName, &$form) {
  if ($formName == 'CRM_Contribute_Form_AdditionalPayment') {
    $buttons = $form->getElement('buttons');
    $elements = $buttons->getElements();
    $elements[0]->setValue("Record Payment");
  }
}

@ahed-compucorp ahed-compucorp force-pushed the MAE-492-fix-membership-end-date-after-Civi-5.35 branch from e557561 to 5883b6e Compare March 16, 2021 15:54
@ahed-compucorp ahed-compucorp merged commit af56b58 into MAE-483-workstream-civi5.35 Mar 18, 2021
@ahed-compucorp ahed-compucorp deleted the MAE-492-fix-membership-end-date-after-Civi-5.35 branch March 18, 2021 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants