From 4a004c120d497f227165d98c81e828998fdd276c Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 16 Apr 2021 07:33:23 +1000 Subject: [PATCH] dev/event#53 Fix issue where by Sold out option was not being properly frozen --- CRM/Price/BAO/PriceField.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index 7ec7366ad9..8d1113244b 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -436,13 +436,6 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { if ($is_pay_later) { $qf->add('text', 'txt-' . $elementName, $label, ['size' => '4']); } - - // CRM-6902 - Add "max" option for a price set field - if (in_array($opId, $freezeOptions)) { - self::freezeIfEnabled($choice[$opId], $customOption[$opId]); - // CRM-14696 - Improve display for sold out price set options - $choice[$opt['id']] = '' . $opt['label'] . ' (' . ts('Sold out') . ')'; - } } if (!empty($qf->_membershipBlock) && $field->name == 'contribution_amount') { $choice['-1'] = ts('No thank you'); @@ -470,6 +463,14 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } $element = &$qf->addRadio($elementName, $label, $choice, [], NULL, FALSE, $choiceAttrs); + foreach ($element->getElements() as $radioElement) { + // CRM-6902 - Add "max" option for a price set field + if (in_array($radioElement->getValue(), $freezeOptions)) { + self::freezeIfEnabled($radioElement, $customOption[$radioElement->getValue()]); + // CRM-14696 - Improve display for sold out price set options + $radioElement->setText('' . $radioElement->getText() . ' (' . ts('Sold out') . ')'); + } + } // make contribution field required for quick config when membership block is enabled if (($field->name == 'membership_amount' || $field->name == 'contribution_amount') -- 2.25.1