Skip to content

Commit

Permalink
Merge pull request #22288 from eileenmcnaughton/process
Browse files Browse the repository at this point in the history
[REF] move code into the function
  • Loading branch information
colemanw authored Dec 22, 2021
2 parents 66cb2c7 + c8ce926 commit 0839808
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2331,27 +2331,6 @@ protected function processFormSubmission($contactID) {

// store the fact that this is a membership and membership type is selected
if ($this->isMembershipSelected($membershipParams)) {
if (!$this->_useForMember) {
$this->assign('membership_assign', TRUE);
$this->set('membershipTypeID', $this->_params['selectMembership']);
}

if ($this->_action & CRM_Core_Action::PREVIEW) {
$membershipParams['is_test'] = 1;
}
if ($this->_params['is_pay_later']) {
$membershipParams['is_pay_later'] = 1;
}

if (isset($this->_params['onbehalf_contact_id'])) {
$membershipParams['onbehalf_contact_id'] = $this->_params['onbehalf_contact_id'];
}
//inherit campaign from contribution page.
if (!array_key_exists('campaign_id', $membershipParams)) {
$membershipParams['campaign_id'] = $this->_values['campaign_id'] ?? NULL;
}

$this->_params = CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $membershipParams, TRUE);
$this->doMembershipProcessing($contactID, $membershipParams, $premiumParams, $this->_lineItem);
}
else {
Expand Down Expand Up @@ -2453,6 +2432,28 @@ private function getMembershipParamsFromPriceSet($membershipParams) {
* @param array $formLineItems
*/
protected function doMembershipProcessing($contactID, $membershipParams, $premiumParams, $formLineItems) {
if (!$this->_useForMember) {
$this->assign('membership_assign', TRUE);
$this->set('membershipTypeID', $this->_params['selectMembership']);
}

if ($this->_action & CRM_Core_Action::PREVIEW) {
$membershipParams['is_test'] = 1;
}
if ($this->_params['is_pay_later']) {
$membershipParams['is_pay_later'] = 1;
}

if (isset($this->_params['onbehalf_contact_id'])) {
$membershipParams['onbehalf_contact_id'] = $this->_params['onbehalf_contact_id'];
}
//inherit campaign from contribution page.
if (!array_key_exists('campaign_id', $membershipParams)) {
$membershipParams['campaign_id'] = $this->_values['campaign_id'] ?? NULL;
}

$this->_params = CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $membershipParams, TRUE);

// This could be set by a hook.
if (!empty($this->_params['installments'])) {
$membershipParams['installments'] = $this->_params['installments'];
Expand Down

0 comments on commit 0839808

Please sign in to comment.