From 0d1c70d5646c6237fa1e4d74a1f1cadc80104cd2 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Thu, 23 Dec 2021 10:13:31 -0500 Subject: [PATCH] Event Registration: allow default Price Set values from the URL --- CRM/Event/Form/Registration/Register.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index 0e8ec10c66..f220988703 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -288,13 +288,22 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { } $optionFullIds = CRM_Utils_Array::value('option_full_ids', $val, []); foreach ($val['options'] as $keys => $values) { - if ($values['is_default'] && empty($values['is_full'])) { - - if ($val['html_type'] == 'CheckBox') { - $this->_defaults["price_{$key}"][$keys] = 1; - } - else { - $this->_defaults["price_{$key}"] = $keys; + $priceFieldName = 'price_' . $values['price_field_id']; + $priceFieldValue = CRM_Price_BAO_PriceSet::getPriceFieldValueFromURL($this, $priceFieldName); + if (!empty($priceFieldValue)) { + CRM_Price_BAO_PriceSet::setDefaultPriceSetField($priceFieldName, $priceFieldValue, $val['html_type'], $this->_defaults); + // break here to prevent overwriting of default due to 'is_default' + // option configuration. The value sent via URL get's higher priority. + break; + } + else { + if ($values['is_default'] && empty($values['is_full'])) { + if ($val['html_type'] == 'CheckBox') { + $this->_defaults["price_{$key}"][$keys] = 1; + } + else { + $this->_defaults["price_{$key}"] = $keys; + } } } } -- 2.25.1