* Process price set and line items.
*
* @param int $entityId
- * @param array $lineItem
+ * @param array $lineItems
* Line item array.
* @param object $contributionDetails
* @param string $entityTable
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
- public static function processPriceSet($entityId, $lineItem, $contributionDetails = NULL, $entityTable = 'civicrm_contribution', $update = FALSE) {
- if (!$entityId || !is_array($lineItem)
- || CRM_Utils_System::isNull($lineItem)
+ public static function processPriceSet($entityId, $lineItems, $contributionDetails = NULL, $entityTable = 'civicrm_contribution', $update = FALSE) {
+ if (!$entityId || !is_array($lineItems)
+ || CRM_Utils_System::isNull($lineItems)
) {
return;
}
- foreach ($lineItem as $priceSetId => &$values) {
+ foreach ($lineItems as $priceSetId => &$values) {
if (!$priceSetId) {
continue;
}
if (!empty($line['price_field_value_id']) && empty($line['financial_type_id'])) {
$line['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $line['price_field_value_id'], 'financial_type_id');
}
- $lineItems = CRM_Price_BAO_LineItem::create($line);
+ $createdLineItem = CRM_Price_BAO_LineItem::create($line);
if (!$update && $contributionDetails) {
- $financialItem = CRM_Financial_BAO_FinancialItem::add($lineItems, $contributionDetails);
+ $financialItem = CRM_Financial_BAO_FinancialItem::add($createdLineItem, $contributionDetails);
$line['financial_item_id'] = $financialItem->id;
if (!empty($line['tax_amount'])) {
- CRM_Financial_BAO_FinancialItem::add($lineItems, $contributionDetails, TRUE);
+ CRM_Financial_BAO_FinancialItem::add($createdLineItem, $contributionDetails, TRUE);
}
}
}
}
if (!$update && $contributionDetails) {
- CRM_Core_BAO_FinancialTrxn::createDeferredTrxn($lineItem, $contributionDetails);
+ CRM_Core_BAO_FinancialTrxn::createDeferredTrxn($lineItems, $contributionDetails);
}
}