*/
protected function setPriceFieldMetadata(array $metadata): void {
foreach ($metadata as $index => $priceField) {
+ if ($this->isExcludeExpiredFields && !$priceField['is_active']) {
+ unset($metadata[$index]);
+ }
if ($this->isExcludeExpiredFields && !empty($priceField['active_on']) && time() < strtotime($priceField['active_on'])) {
unset($metadata[$index]);
}
}
elseif (!empty($priceField['options'])) {
foreach ($priceField['options'] as $optionID => $option) {
- if (!empty($option['membership_type_id'])) {
+ if (!$option['is_active']) {
+ unset($metadata[$index]['options'][$optionID]);
+ }
+ elseif (!empty($option['membership_type_id'])) {
$membershipType = CRM_Member_BAO_MembershipType::getMembershipType((int) $option['membership_type_id']);
$metadata[$index]['options'][$optionID]['auto_renew'] = (int) $membershipType['auto_renew'];
if ($membershipType['auto_renew'] && empty($this->priceSetMetadata['auto_renew_membership_field'])) {
return $result;
}
+ public static function hook_civicrm_post($op, $objectName, $objectId, &$objectRef): void {
+ if (in_array($objectName, ['PriceField', 'PriceFieldValue', 'PriceSet'], TRUE)) {
+ self::flushPriceSets();
+ }
+ }
+
+ public static function flushPriceSets(): void {
+ $cache = CRM_Utils_Cache::singleton();
+ foreach (PriceSet::get(FALSE)->addSelect('id')->execute() as $priceSet) {
+ $cacheKey = 'CRM_Price_BAO_PriceSetgetCachedPriceSetDetail_' . $priceSet['id'];
+ $cache->delete($cacheKey);
+ }
+ }
+
}
if ( !memTypeId ) memTypeId = cj('input:radio[name='+priceSetName+']:checked').attr('membership-type');
//does this page has only one membership type.
- var singleMembership = {/literal}'{$singleMembership}'{literal};
- if ( !memTypeId && singleMembership ) memTypeId = cj("input:radio[name="+priceSetName+"]").attr('membership-type');
var renewOptions = {/literal}{$autoRenewMembershipTypeOptions}{literal};
var currentOption = eval( "renewOptions." + 'autoRenewMembershipType_' + memTypeId );
var autoRenew = cj('#auto_renew_section');