public $_membershipTypeValues;
- public $_useForMember;
-
/**
* Array of payment related fields to potentially display on this form (generally credit card or debit card fields). This is rendered via billingBlock.tpl
* @var array
$entityId = $memtypeID = NULL;
if ($this->_priceSetId) {
- if (($this->_useForMember && !empty($this->_currentMemberships)) || $this->_defaultMemTypeId) {
+ if (($this->isMembershipPriceSet() && !empty($this->_currentMemberships)) || $this->_defaultMemTypeId) {
$selectedCurrentMemTypes = [];
foreach ($this->_priceSet['fields'] as $key => $val) {
foreach ($val['options'] as $keys => $values) {
}
//build pledge block.
- $this->_useForMember = 0;
//don't build membership block when pledge_id is passed
if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
$this->_separateMembershipPayment = FALSE;
if (CRM_Core_Component::isEnabled('CiviMember')) {
-
- if ($this->_priceSetId &&
- (CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet))
- ) {
- $this->_useForMember = 1;
- $this->set('useForMember', $this->_useForMember);
- }
-
$this->_separateMembershipPayment = $this->buildMembershipBlock();
}
$this->set('separateMembershipPayment', $this->_separateMembershipPayment);
}
- $this->assign('useForMember', $this->_useForMember);
+
+ $this->assign('useForMember', (int) $this->isMembershipPriceSet());
// If we configured price set for contribution page
// we are not allow membership signup as well as any
// other contribution amount field, CRM-5095
}
}
- if ($this->_priceSetId && empty($this->_ccid)) {
- $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
- if ($is_quick_config) {
- $this->_useForMember = 0;
- $this->set('useForMember', $this->_useForMember);
- }
- }
-
//we allow premium for pledge during pledge creation only.
if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
$this->_currentMemberships = [];
$membershipTypeIds = $membershipTypes = $radio = $radioOptAttrs = [];
- $membershipPriceset = (!empty($this->_priceSetId) && $this->_useForMember);
+ $membershipPriceset = (!empty($this->_priceSetId) && $this->isMembershipPriceSet());
$allowAutoRenewMembership = $autoRenewOption = FALSE;
$autoRenewMembershipTypeOptions = [];
$errors["price_{$otherAmount}"] = ts('Amount is required field.');
}
- if ($self->_useForMember == 1 && !empty($check) && $membershipIsActive) {
+ if ($self->isMembershipPriceSet() && !empty($check) && $membershipIsActive) {
$priceFieldIDS = [];
$priceFieldMemTypes = [];
public $_paymentObject = NULL;
+ /**
+ * Order object, used to calculate amounts, line items etc.
+ *
+ * @var \CRM_Financial_BAO_Order
+ */
+ protected $order;
+
/**
* The membership block for this page
*
$this->_bltID = $this->get('bltID');
$this->_paymentProcessor = $this->get('paymentProcessor');
- // This get will ensure it is set for later. Once we are sure all places
- // access via the get & not directly, it can go.
- $this->getPriceSetID();
+ $this->order = new CRM_Financial_BAO_Order();
+ $this->order->setPriceSetID($this->getPriceSetID());
$this->_priceSet = $this->get('priceSet');
if (!$this->_values) {
return $this->_membershipBlock;
}
+ /**
+ * Is a (non-quick-config) membership price set in use.
+ *
+ * @return bool
+ */
+ protected function isMembershipPriceSet(): bool {
+ if ($this->_useForMember === NULL) {
+ if (CRM_Core_Component::isEnabled('CiviMember') &&
+ (!$this->isQuickConfig() || !empty($this->_ccid)) &&
+ CRM_Core_Component::getComponentID('CiviMember') === (int) $this->order->getPriceSetMetadata()['extends']) {
+ $this->_useForMember = 1;
+ }
+ else {
+ $this->_useForMember = 0;
+ }
+ $this->set('useForMember', $this->_useForMember);
+ }
+ return (bool) $this->_useForMember;
+ }
+
/**
* Is the contribution page configured for 2 payments, one being membership & one not.
*