$membershipParams['cms_contactID'] = $contactID;
}
- //inherit campaign from contirb page.
+ //inherit campaign from contribution page.
if (!array_key_exists('campaign_id', $membershipParams)) {
$membershipParams['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values);
}
}
if (!empty($membershipParams['selectMembership'])) {
// CRM-12233
+ $membershipLineItems = array();
if ($this->_separateMembershipPayment && $this->_values['amount_block_is_active']) {
foreach ($this->_values['fee'] as $key => $feeValues) {
- if ($feeValues['name'] == 'membership_amount') {
+ if ($feeValues['name'] == 'membership_amount') {
$fieldId = $this->_params['price_' . $key];
- $this->_memLineItem[$this->_priceSetId][$fieldId] = $this->_lineItem[$this->_priceSetId][$fieldId];
+ $membershipLineItems[$this->_priceSetId][$fieldId] = $this->_lineItem[$this->_priceSetId][$fieldId];
unset($this->_lineItem[$this->_priceSetId][$fieldId]);
break;
}
}
}
- $this->processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams);
+ $this->processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems);
if (!$this->_amount > 0.0 || !$membershipParams['amount']) {
// we need to explicitly create a CMS user in case of free memberships
// since it is done under processConfirm for paid memberships
}
/**
- * @param $membershipParams
- * @param $contactID
- * @param $customFieldsFormatted
- * @param $fieldTypes
- * @param $premiumParams
+ * @param array $membershipParams
+ * @param integer $contactID
+ * @param array $customFieldsFormatted
+ * @param array $fieldTypes
+ * @param array $premiumParams
+ * @param array $membershipLineItems line items specifically relating to memberships
*/
- public function processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams)
- {
+ public function processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems) {
try {
+ $membershipTypeID = (array) $membershipParams['selectMembership'];
- $membershipTypeID = $membershipParams['selectMembership'];
+ $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this);
+
+ $membershipType = empty($membershipTypes) ? array() : reset($membershipTypes);
+ $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
- $membershipDetails = CRM_Member_BAO_Membership::buildMembershipTypeValues($this);
- $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipDetails));
$isPaidMembership = FALSE;
if($this->_amount > 0.0 && $membershipParams['amount']) {
//amount must be greater than zero for
$contributionTypeId = $this->_values['financial_type_id'];
}
else {
- $contributionTypeId = CRM_Utils_Array::value( 'financial_type_id', $membershipDetails );
- if (!$contributionTypeId) {
- $contributionTypeId = CRM_Utils_Array::value('financial_type_id' ,$membershipParams);
- }
+ $contributionTypeId = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id' ,$membershipParams));
}
CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
- $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipDetails, $membershipTypeID, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId
+ $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeID, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId,
+ $membershipLineItems
);
$this->assign('membership_assign', TRUE);
$this->set('membershipTypeID', $membershipParams['selectMembership']);
// but the circumstances are very confusing. Many of these conditions are repeated in the next conditional
// so we should merge them together
// the quick config seems like a red-herring - if this is about a separate membership payment then there
- // are 2 types of line items - membership ones & non-membership ones - regardless of whether quickconfig is set
+ // are 2 types of line items - membership ones & non-membership ones - regardless of whether quick config is set
elseif (
CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock)
&& !empty($this->_values['fee'][$priceField->id])
static function submit($params) {
$form = new CRM_Contribute_Form_Contribution_Confirm();
$form->_id = $params['id'];
+ CRM_Contribute_BAO_ContributionPage::setValues($form->_id, $form->_values);
+ $form->_separateMembershipPayment = CRM_Contribute_BAO_ContributionPage::getIsMembershipPayment($form->_id);
//this way the mocked up controller ignores the session stuff
$_SERVER['REQUEST_METHOD'] = 'GET';
$form->controller = new CRM_Contribute_Controller_Contribution();
$params['invoiceID'] = md5(uniqid(rand(), TRUE));
$paramsProcessedForForm = $form->_params = self::getFormParams($params['id'], $params);
+ $form->_amount = $params['amount'];
+
$priceSetID = $form->_params['priceSetId'] = $paramsProcessedForForm['price_set_id'];
$priceFields = CRM_Price_BAO_PriceSet::getSetDetail($priceSetID);
+ $priceSetFields = reset($priceFields);
+ $form->_values['fee'] = $priceSetFields['fields'];
+ $form->_priceSetId = $priceSetID;
$form->setFormAmountFields($priceSetID);
$priceFields = $priceFields[$priceSetID]['fields'];
CRM_Price_BAO_PriceSet::processAmount($priceFields, $paramsProcessedForForm, $lineItems, 'civicrm_contribution');