From ea7adf56579bd0e22b8665b1b04044bff0aee205 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 25 Sep 2023 09:53:39 +1300 Subject: [PATCH] Revove always true if --- CRM/Event/Form/Registration.php | 72 ++++++++++++++++----------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 640e9d5cec..6746b52f62 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -586,56 +586,54 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { } // get price info - if ($priceSetId) { - if ($form->_action & CRM_Core_Action::UPDATE) { - if (in_array(CRM_Utils_System::getClassName($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register'])) { - $form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($form->_id, 'participant'); - } - else { - $form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($form->_participantId, 'participant'); - } + if ($form->_action & CRM_Core_Action::UPDATE) { + if (in_array(CRM_Utils_System::getClassName($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register'])) { + $form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($form->_id, 'participant'); } - $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, NULL, $doNotIncludeExpiredFields); - $form->_priceSet = $priceSet[$priceSetId] ?? NULL; - $form->_values['fee'] = $form->_priceSet['fields'] ?? NULL; - - //get the price set fields participant count. - //get option count info. - $form->_priceSet['optionsCountTotal'] = CRM_Price_BAO_PriceSet::getPricesetCount($priceSetId); - if ($form->_priceSet['optionsCountTotal']) { - $optionsCountDetails = []; - if (!empty($form->_priceSet['fields'])) { - foreach ($form->_priceSet['fields'] as $field) { - foreach ($field['options'] as $option) { - $count = CRM_Utils_Array::value('count', $option, 0); - $optionsCountDetails['fields'][$field['id']]['options'][$option['id']] = $count; - } - } - } - $form->_priceSet['optionsCountDetails'] = $optionsCountDetails; + else { + $form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($form->_participantId, 'participant'); } + } + $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, NULL, $doNotIncludeExpiredFields); + $form->_priceSet = $priceSet[$priceSetId] ?? NULL; + $form->_values['fee'] = $form->_priceSet['fields'] ?? NULL; - //get option max value info. - $optionsMaxValueTotal = 0; - $optionsMaxValueDetails = []; - + //get the price set fields participant count. + //get option count info. + $form->_priceSet['optionsCountTotal'] = CRM_Price_BAO_PriceSet::getPricesetCount($priceSetId); + if ($form->_priceSet['optionsCountTotal']) { + $optionsCountDetails = []; if (!empty($form->_priceSet['fields'])) { foreach ($form->_priceSet['fields'] as $field) { foreach ($field['options'] as $option) { - $maxVal = CRM_Utils_Array::value('max_value', $option, 0); - $optionsMaxValueDetails['fields'][$field['id']]['options'][$option['id']] = $maxVal; - $optionsMaxValueTotal += $maxVal; + $count = CRM_Utils_Array::value('count', $option, 0); + $optionsCountDetails['fields'][$field['id']]['options'][$option['id']] = $count; } } } + $form->_priceSet['optionsCountDetails'] = $optionsCountDetails; + } + + //get option max value info. + $optionsMaxValueTotal = 0; + $optionsMaxValueDetails = []; - $form->_priceSet['optionsMaxValueTotal'] = $optionsMaxValueTotal; - if ($optionsMaxValueTotal) { - $form->_priceSet['optionsMaxValueDetails'] = $optionsMaxValueDetails; + if (!empty($form->_priceSet['fields'])) { + foreach ($form->_priceSet['fields'] as $field) { + foreach ($field['options'] as $option) { + $maxVal = CRM_Utils_Array::value('max_value', $option, 0); + $optionsMaxValueDetails['fields'][$field['id']]['options'][$option['id']] = $maxVal; + $optionsMaxValueTotal += $maxVal; + } } - $form->set('priceSet', $form->_priceSet); } + $form->_priceSet['optionsMaxValueTotal'] = $optionsMaxValueTotal; + if ($optionsMaxValueTotal) { + $form->_priceSet['optionsMaxValueDetails'] = $optionsMaxValueDetails; + } + $form->set('priceSet', $form->_priceSet); + $eventFee = $form->_values['fee'] ?? NULL; if (!is_array($eventFee) || empty($eventFee)) { $form->_values['fee'] = []; -- 2.25.1