Skip to content

Commit

Permalink
BTHA-194: Ensure membeership rate total can be calculated for line item
Browse files Browse the repository at this point in the history
  • Loading branch information
olayiwola-compucorp committed Sep 6, 2024
1 parent 1275459 commit ac45551
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CRM_MembershipExtras_Hook_Pre_MembershipPaymentPlanProcessor_LineItem exte

public function __construct(&$params) {
$this->params = &$params;
$this->setContactID();
$this->assignInstalmentDetails();
}

Expand Down Expand Up @@ -73,4 +74,17 @@ protected function getLineItemCount(): int {
return CRM_Utils_Array::value('lineItemCount', $this->params, 1);
}

private function setContactID() {
if (!empty($this->params['contact_id']) || empty($this->params['contribution_id'])) {
return;
}

$this->params['contact_id'] = \Civi\Api4\Contribution::get()
->addSelect('contact_id')
->addWhere('id', '=', $this->params['contribution_id'])
->setLimit(1)
->execute()
->first()['contact_id'] ?? NULL;
}

}

0 comments on commit ac45551

Please sign in to comment.