}
$is_pay_later = 0;
+ $isQuickConfig = CRM_Price_BAO_PriceSet::isQuickConfig($field->price_set_id);
if (isset($qf->_mode) && empty($qf->_mode)) {
$is_pay_later = 1;
}
]);
$extra = [];
- if (!empty($qf->_membershipBlock) && !empty($qf->_quickConfig) && $field->name == 'other_amount' && empty($qf->_contributionAmount)) {
+ if (!empty($qf->_membershipBlock) && $isQuickConfig && $field->name == 'other_amount' && empty($qf->_contributionAmount)) {
$useRequired = 0;
}
elseif (!empty($fieldOptions[$optionKey]['label'])) {
//check for label.
$label = $fieldOptions[$optionKey]['label'];
- if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount) && strtolower($fieldOptions[$optionKey]['name']) == 'other_amount') {
+ if ($isQuickConfig && !empty($qf->_contributionAmount) && strtolower($fieldOptions[$optionKey]['name']) == 'other_amount') {
$label .= ' ' . $currencySymbol;
$qf->assign('priceset', $elementName);
$extra = [
}
//CRM-10117
- if (!empty($qf->_quickConfig)) {
+ if ($isQuickConfig) {
$message = ts('Please enter a valid amount.');
$type = 'money';
}
case 'Radio':
$choice = [];
- if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount)) {
+ if ($isQuickConfig && !empty($qf->_contributionAmount)) {
$qf->assign('contriPriceset', $elementName);
}
'data-price-field-values' => json_encode($customOption),
'visibility' => $visibility_id,
];
- if (!empty($qf->_quickConfig) && $field->name == 'contribution_amount') {
+ if ($isQuickConfig && $field->name == 'contribution_amount') {
$extra += ['onclick' => 'clearAmountOther();'];
}
if ($field->name == 'membership_amount') {
return $setTree;
}
+ /**
+ * Is the price set 'quick config'.
+ *
+ * Quick config price sets have a simplified configuration on
+ * contribution and event pages.
+ *
+ * @param int $priceSetID
+ *
+ * @return bool
+ */
+ public static function isQuickConfig(int $priceSetID): bool {
+ return (bool) self::getCachedPriceSetDetail($priceSetID)['is_quick_config'];
+ }
+
/**
* Get the Price Field ID.
*
public static function copyPriceSet($baoName, $id, $newId) {
$priceSetId = CRM_Price_BAO_PriceSet::getFor($baoName, $id);
if ($priceSetId) {
- $isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config');
- if ($isQuickConfig) {
+ if (self::isQuickConfig($priceSetId)) {
$copyPriceSet = CRM_Price_BAO_PriceSet::copy($priceSetId);
CRM_Price_BAO_PriceSet::addTo($baoName, $newId, $copyPriceSet->id);
}