}
}
}
-
- // if auto renew checkbox is set, initiate a open-ended recurring membership
- if ((!empty($this->_params['selectMembership']) || !empty($this->_params['priceSetId'])) && !empty($this->_paymentProcessor['is_recur']) &&
- CRM_Utils_Array::value('auto_renew', $this->_params) && empty($this->_params['is_recur']) && empty($this->_params['frequency_interval'])
- ) {
-
- $this->_params['is_recur'] = $this->_values['is_recur'] = 1;
- // check if price set is not quick config
- if (!empty($this->_params['priceSetId']) && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_params['priceSetId'], 'is_quick_config')) {
- list($this->_params['frequency_interval'], $this->_params['frequency_unit']) = CRM_Price_BAO_PriceSet::getRecurDetails($this->_params['priceSetId']);
- }
- else {
- // FIXME: set interval and unit based on selected membership type
- $this->_params['frequency_interval'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
- $this->_params['selectMembership'], 'duration_interval'
- );
- $this->_params['frequency_unit'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
- $this->_params['selectMembership'], 'duration_unit'
- );
- }
- }
+ $this->setRecurringMembershipParams();
if ($this->_pcpId) {
$params = $this->processPcp($this, $this->_params);
((float ) $params['amount'] > 0.0 || $memFee > 0.0)
) {
$this->setContributeMode();
-
+ // Really this setting of $this->_params & params within it should be done earlier on in the function
+ // probably the values determined here should be reused in confirm postProcess as there is no opportunity to alter anything
+ // on the confirm page. However as we are dealing with a stable release we go as close to where it is used
+ // as possible.
+ // In general the form has a lack of clarity of the logic of why things are set on the form in some cases &
+ // the logic around when $this->_params is used compared to other params arrays.
+ $this->_params = array_merge($params, $this->_params);
+ $this->setRecurringMembershipParams();
if ($this->_paymentProcessor &&
$this->_paymentProcessor['object']->supports('preApproval')
) {
- $this->handlePreApproval($params);
+ $this->handlePreApproval($this->_params);
}
}
*
* @var array
*/
- public $_params;
+ public $_params = array();
/**
* The fields involved in this contribution page
return $separateMembershipPayment;
}
+ /**
+ * Determine if recurring parameters need to be added to the form parameters.
+ * - is_recur
+ * - frequency_interval
+ * - frequency_unit
+ *
+ * For membership this is based on the membership type.
+ *
+ * This needs to be done before processing the pre-approval redirect where relevant on the main page or before any payment processing.
+ *
+ * Arguably the form should start to build $this->_params in the pre-process main page & use that array consistently throughout.
+ */
+ protected function setRecurringMembershipParams() {
+ if ((!empty($this->_params['selectMembership']) || !empty($this->_params['priceSetId'])) && !empty($this->_paymentProcessor['is_recur']) &&
+ CRM_Utils_Array::value('auto_renew', $this->_params) && empty($this->_params['is_recur']) && empty($this->_params['frequency_interval'])
+ ) {
+
+ $this->_params['is_recur'] = $this->_values['is_recur'] = 1;
+ // check if price set is not quick config
+ if (!empty($this->_params['priceSetId']) && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_params['priceSetId'], 'is_quick_config')) {
+ list($this->_params['frequency_interval'], $this->_params['frequency_unit']) = CRM_Price_BAO_PriceSet::getRecurDetails($this->_params['priceSetId']);
+ }
+ else {
+ // FIXME: set interval and unit based on selected membership type
+ $this->_params['frequency_interval'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
+ $this->_params['selectMembership'], 'duration_interval'
+ );
+ $this->_params['frequency_unit'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
+ $this->_params['selectMembership'], 'duration_unit'
+ );
+ }
+ }
+ }
+
}