From 0ec24d62be937534c0e390d629d26a2ba7d6b6c6 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 28 Jun 2022 17:45:59 +1200 Subject: [PATCH] Ensure apiv3 params are converted at the line item level We switched to using apiv4 but at least one test seems to be passing in a string at the line item level which is a bit weird but we should handle it --- api/v3/Order.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/v3/Order.php b/api/v3/Order.php index 400bef6f12..3b495b93a2 100644 --- a/api/v3/Order.php +++ b/api/v3/Order.php @@ -94,6 +94,10 @@ function civicrm_api3_order_create(array $params): array { $order->setEntityParameters($lineItems['params'], $index); } foreach ($lineItems['line_item'] as $innerIndex => $lineItem) { + // For historical reasons it might be name. + if (!empty($lineItem['membership_type_id']) && !is_numeric($lineItem['membership_type_id'])) { + $lineItem['membership_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Member_BAO_Membership', 'membership_type_id', $lineItems['params']['membership_type_id']); + } $lineIndex = $index . '+' . $innerIndex; $order->setLineItem($lineItem, $lineIndex); $order->addLineItemToEntityParameters($lineIndex, $index); -- 2.25.1