Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Jul 31, 2023
1 parent 4407503 commit 3a5e997
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/WebformCivicrmPostProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -2344,22 +2344,24 @@ private function processContribution() {
// Membership
if (!empty($item['membership_id'])) {
$item['entity_id'] = $item['membership_id'];
$lineItemArray = $this->utils->wf_civicrm_api('LineItem', 'get', [
'entity_table' => "civicrm_membership",
'entity_id' => $item['entity_id'],
]);
if ($lineItemArray['count'] != 0) {
// We only require first membership (signup) entry to make this work.
$firstLineItem = array_shift($lineItemArray['values']);

// We only require first membership (signup) entry to make this work.
$firstMembershipLineItem = $this->utils->wf_civicrm_api4('LineItem', 'get', [
'where' => [
['entity_table', '=', 'civicrm_membership'],
['entity_id', '=', $item['entity_id']],
],
],
0,
);
if (!empty($firstMembershipLineItem)) {
// Membership signup line item entry.
// Line Item record is already present for membership by this stage.
// Just need to upgrade contribution_id column in the record.
if (!isset($firstLineItem['contribution_id'])) {
$item['id'] = $firstLineItem['id'];
if (!isset($firstMembershipLineItem['contribution_id'])) {
$item['id'] = $firstMembershipLineItem['id'];
}
$item['price_field_id'] = $firstLineItem['price_field_id'];
$item['price_field_value_id'] = $firstLineItem['price_field_value_id'];
$item['price_field_id'] = $firstMembershipLineItem['price_field_id'];
$item['price_field_value_id'] = $firstMembershipLineItem['price_field_value_id'];
}
}
if (!isset($item['price_field_id'])) {
Expand All @@ -2373,6 +2375,7 @@ private function processContribution() {
}

// Save the line_item
var_dump($item);
$line_result = $this->utils->wf_civicrm_api('line_item', 'create', $item);
$item['id'] = $line_result['id'];

Expand Down

0 comments on commit 3a5e997

Please sign in to comment.