Skip to content

Commit

Permalink
CIVICRM-2206 Use first pricefield ID when inferring membership type I…
Browse files Browse the repository at this point in the history
…D from checkboxes
  • Loading branch information
agileware-fj committed Mar 7, 2024
1 parent 4b75775 commit a0ad016
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CRM/Contribute/Form/Contribution/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,16 @@ public function setDefaultValues() {
elseif (!empty($priceFieldOption['is_default']) && (!isset($this->_defaults[$priceFieldName]) ||
($val['html_type'] === 'CheckBox' && !isset($this->_defaults[$priceFieldName][$keys])))) {
CRM_Price_BAO_PriceSet::setDefaultPriceSetField($priceFieldName, $keys, $val['html_type'], $this->_defaults);
$memtypeID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_defaults[$priceFieldName], 'membership_type_id');
// When the membership price field is checkboxes, the defaults are an array keyed with
// the priceFieldValue ids. CRM_Core_DAO::getFieldValue expects something that can be
// autocast to a string, so just get the first key
$priceFieldName_default = $this->_defaults[$priceFieldName];
if (is_array($priceFieldName_default)) {
$priceFieldName_default = array_keys(array_filter($priceFieldName_default))[0] ?? NULL;
}
if (!is_null($priceFieldName_default)) {
$memtypeID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldName_default, 'membership_type_id');
}
}
}
}
Expand Down

0 comments on commit a0ad016

Please sign in to comment.