From 91a1961852c28eb20396f52ad3ffc505603d97fb Mon Sep 17 00:00:00 2001 From: brienne Date: Wed, 16 Aug 2023 17:23:38 -0400 Subject: [PATCH] membership price fix with API from 5.65 --- CRM/Member/Form/MembershipBlock.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/CRM/Member/Form/MembershipBlock.php b/CRM/Member/Form/MembershipBlock.php index 179c437a6c..7834352d4f 100644 --- a/CRM/Member/Form/MembershipBlock.php +++ b/CRM/Member/Form/MembershipBlock.php @@ -241,15 +241,18 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa } } if (!empty($params['member_is_active'])) { - - // don't allow price set w/ membership signup, CRM-5095 - if ($contributionPageId && ($setID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $contributionPageId, NULL, 1))) { - - $extends = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'extends'); - if ($extends != CRM_Core_Component::getComponentID('CiviMember')) { - $errors['member_is_active'] = ts('You cannot enable both Membership Signup and a Contribution Price Set on the same online contribution page.'); - return $errors; - } + // Don't allow Contribution price set w/ membership signup, CRM-5095. + $priceSetExtendsMembership = \Civi\Api4\PriceSetEntity::get(FALSE) + ->addSelect('id') + ->addJoin('PriceSet AS price_set', 'LEFT', ['price_set_id', '=', 'price_set.id']) + ->addWhere('entity_table', '=', 'civicrm_contribution_page') + ->addWhere('entity_id', '=', $contributionPageId) + ->addWhere('price_set.extends:name', 'CONTAINS', 'CiviMember') + ->execute() + ->first(); + if (!$priceSetExtendsMembership) { + $errors['member_is_active'] = ts('You cannot enable both Membership Signup and a Contribution Price Set on the same online contribution page.'); + return $errors; } if (!empty($params['member_price_set_id'])) { -- 2.25.1