]
);
$this->ids['Contribution'] = $contribution['id'];
- $this->setMembershipIDs($contribution['values'][$contribution['id']]['membership_id']);
+ $this->setMembershipIDsFromOrder($contribution);
//create new soft-credit record, CRM-13981
if ($softParams) {
return array_merge($this->getFormMembershipParams(), $this->getMembershipParameters()[$membershipTypeID]);
}
+ /**
+ * @param array $contribution
+ */
+ protected function setMembershipIDsFromOrder(array $contribution): void {
+ $ids = [];
+ foreach ($contribution['values'][$contribution['id']]['line_item'] as $line) {
+ if ($line['entity_table'] ?? '' === 'civicrm_membership') {
+ $ids[] = $line['entity_id'];
+ }
+ }
+ $this->setMembershipIDs($ids);
+ }
+
}
$entity = NULL;
$entityIds = [];
$params['contribution_status_id'] = 'Pending';
+ $priceSetID = NULL;
if (!empty($params['line_items']) && is_array($params['line_items'])) {
- $priceSetID = NULL;
CRM_Contribute_BAO_Contribution::checkLineItems($params);
foreach ($params['line_items'] as $lineItems) {
$entityParams = $lineItems['params'] ?? [];
}
$contribution = civicrm_api3('Contribution', 'create', $contributionParams);
+ $contribution['values'][$contribution['id']]['line_item'] = $params['line_item'][$priceSetID] ?? [];
+
// add payments
if ($entity && !empty($contribution['id'])) {
foreach ($entityIds as $entityId) {
$paymentParams += $entityParams;
}
elseif ($entity === 'membership') {
- $contribution['values'][$contribution['id']]['membership_id'][] = $entityId;
$paymentParams['isSkipLineItem'] = TRUE;
}
civicrm_api3($entity . '_payment', 'create', $paymentParams);
]);
$this->ids['Contribution'][0] = $order['id'];
- $this->ids['Membership']['order'] = $order['values'][$order['id']]['membership_id'][0];
+ foreach ($order['values'][$order['id']]['line_item'] as $line) {
+ if (($line['entity_table'] ?? '') === 'civicrm_membership') {
+ $this->ids['Membership']['order'] = $line['entity_id'];
+ }
+ }
+
}
/**