Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
Prevent loss of line-item when multiple price field has same name
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Feb 3, 2021
1 parent 8d3d621 commit 9d0984e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions CRM/Lineitemedit/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,13 +909,20 @@ public static function buildLineItemRows(&$form, $contributionID = NULL) {
}
}
else {
if ($rowNumber == 0) {
$priceFieldValue = civicrm_api3('PriceFieldValue', 'get', ['name' => 'contribution_amount']);
}
else {
$priceFieldValue = civicrm_api3('PriceFieldValue', 'get', ['name' => 'additional_item_' . $rowNumber]);
}
$form->setDefaults(["item_price_field_value_id[$rowNumber]" => $priceFieldValue['id']]);
$priceSetDetails = civicrm_api3('PriceSet', 'get', [
'sequential' => 1,
'name' => "default_contribution_amount",
'is_quick_config' => 1,
'api.PriceField.get' => [
'sequential' => 1,
'price_set_id' => "\$value.id",
'api.PriceFieldValue.get' => [
'sequential' => 1,
'price_field_id' => "\$value.id"
],
],
]);
$form->setDefaults(["item_price_field_value_id[$rowNumber]" => $priceSetDetails['values'][0]['api.PriceField.get']['values'][$rowNumber]['api.PriceFieldValue.get']['id']]);
}
}
}
Expand Down

0 comments on commit 9d0984e

Please sign in to comment.