diff --git a/CRM/MembershipExtras/Hook/Pre/MembershipPaymentPlanProcessor/LineItem.php b/CRM/MembershipExtras/Hook/Pre/MembershipPaymentPlanProcessor/LineItem.php index dc4c7bb7..f11222a0 100644 --- a/CRM/MembershipExtras/Hook/Pre/MembershipPaymentPlanProcessor/LineItem.php +++ b/CRM/MembershipExtras/Hook/Pre/MembershipPaymentPlanProcessor/LineItem.php @@ -8,6 +8,7 @@ class CRM_MembershipExtras_Hook_Pre_MembershipPaymentPlanProcessor_LineItem exte public function __construct(&$params) { $this->params = &$params; + $this->setContactID(); $this->assignInstalmentDetails(); } @@ -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; + } + }