Skip to content

Commit

Permalink
[REF] Load participant id within completeOrder rather than passing it in
Browse files Browse the repository at this point in the history
The participantID passed in is simply loaded by retrieving participant_id from
the participant payment table earlier on. By doing it in the function
instead we can simplify the code that does that. There is no apiv4 for
participant payment as yet and once we start thinking about adding that
other questions arise (should we retrieve it via the line item instead)
so I went for a very limited change that simply replicates the
way it is currently retrieved (and does not, for example, increase the scope
to consider whether Attended should be updated to Registered) - in other
words this is as close to no-change as possible

I also deliberately left any changes to the nasty by-pass out of scope - that
needs to be tackled from the other end - ie removing the reason for the bypass
first and in the meantime we don't want to make it look any less hacky as we
don't want anyone to try to 'use' it
Test cover in testRepeatTransactionPassedInFinancialTypeTwoLineItems
  • Loading branch information
eileenmcnaughton committed Feb 21, 2021
1 parent 3030b08 commit 1759de8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -4198,7 +4198,6 @@ public static function completeOrder($input, $ids, $contributionID, $isPostPayme
// @todo see if we even need this - it's used further down to create an activity
// but the BAO layer should create that - we just need to add a test to cover it & can
// maybe remove $ids altogether.
$participantID = $ids['participant'];
$recurringContributionID = $ids['contributionRecur'];

// Unset ids just to make it clear it's not used again.
Expand Down Expand Up @@ -4253,8 +4252,9 @@ public static function completeOrder($input, $ids, $contributionID, $isPostPayme
}
}
else {
if (empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) {
$participantParams['id'] = $participantID;
$participantPayment = civicrm_api3('ParticipantPayment', 'get', ['contribution_id' => $contributionID, 'return' => 'participant_id', 'sequential' => 1])['values'];
if (!empty($participantPayment) && empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) {
$participantParams['id'] = $participantPayment[0]['participant_id'];
$participantParams['status_id'] = 'Registered';
civicrm_api3('Participant', 'create', $participantParams);
}
Expand Down

0 comments on commit 1759de8

Please sign in to comment.