CRM-16437 fix - Participant export retains all fee levels after change
[civicrm-core.git] / CRM / Event / BAO / Participant.php
index 66b8505504382c6083093180cdc91edb48d76345..235390a5b7d96a0b9108cb74bd276dc526d5d6b9 100644 (file)
@@ -2047,10 +2047,13 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
 
     // update participant fee_amount column
     $partUpdateFeeAmt['id'] = $participantId;
-    foreach ($lineItems as $lineValue) {
-      if ($lineValue['price_field_value_id']) {
-        $line[$lineValue['price_field_value_id']] = $lineValue['label'] . ' - ' . $lineValue['qty'];
-      }
+    $getUpdatedLineItems = "SELECT *
+FROM civicrm_line_item
+WHERE (entity_table = 'civicrm_participant' AND entity_id = {$participantId} AND qty > 0)
+      ";
+    $getUpdatedLineItemsDAO =  CRM_Core_DAO::executeQuery($getUpdatedLineItems);
+    while ($getUpdatedLineItemsDAO->fetch()) {
+      $line[$getUpdatedLineItemsDAO->price_field_value_id] = $getUpdatedLineItemsDAO->label . ' - ' . (float) $getUpdatedLineItemsDAO->qty;
     }
 
     $partUpdateFeeAmt['fee_level'] = implode(', ', $line);