foreach ($this->_relatedObjects['membership'] as $membership) {
if ($membership->id) {
$values['isMembership'] = TRUE;
+ $values['membership_assign'] = TRUE;
// need to set the membership values here
- $template->assign('membership_assign', 1);
$template->assign('membership_name',
CRM_Member_PseudoConstant::membershipType($membership->membership_type_id)
);
$template->assign('sku', $productDAO->sku);
}
$template->assign('title', CRM_Utils_Array::value('title', $values));
- $amount = CRM_Utils_Array::value('total_amount', $input, (CRM_Utils_Array::value('amount', $input)), NULL);
- if (empty($amount) && isset($this->total_amount)) {
- $amount = $this->total_amount;
+ $values['amount'] = CRM_Utils_Array::value('total_amount', $input, (CRM_Utils_Array::value('amount', $input)), NULL);
+ if (!$values['amount'] && isset($this->total_amount)) {
+ $values['amount'] = $this->total_amount;
}
- $template->assign('amount', $amount);
+
// add the new contribution values
if (strtolower($this->_component) == 'contribute') {
//PCP Info
// We are trying to fight the good fight against leaky variables (CRM-17519) so let's get really explicit
// about ensuring the variables we want for the template are defined.
// @todo add to this until all tpl params are explicit in this function and not waltzing around the codebase.
- $valuesRequiredForTemplate = array('customPre', 'customPost', 'customPre_grouptitle', 'customPost_grouptitle',
- 'useForMember');
+ // Next stage is to remove this & ensure there are no e-notices - ie. all are set before they hit this fn.
+ $valuesRequiredForTemplate = array(
+ 'customPre',
+ 'customPost',
+ 'customPre_grouptitle',
+ 'customPost_grouptitle',
+ 'useForMember',
+ 'membership_assign',
+ 'amount',
+ );
+
foreach ($valuesRequiredForTemplate as $valueRequiredForTemplate) {
if (!isset($values[$valueRequiredForTemplate])) {
$values[$valueRequiredForTemplate] = NULL;
'customPost' => $values['customPost'],
'customPost_grouptitle' => $values['customPost_grouptitle'],
'useForMember' => $values['useForMember'],
+ 'membership_assign' => $values['membership_assign'],
+ 'amount' => $values['amount'],
);
if ($contributionTypeId = CRM_Utils_Array::value('financial_type_id', $values)) {
$membershipContribution = NULL;
$isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
$errors = $createdMemberships = $paymentResults = array();
-
+ $form->_values['isMembership'] = TRUE;
$isRecurForFirstTransaction = CRM_Utils_Array::value('is_recur', $form->_values, CRM_Utils_Array::value('is_recur', $membershipParams));
+ $totalAmount = $membershipParams['amount'];
if ($isPaidMembership) {
if ($isProcessSeparateMembershipTransaction) {
return;
}
- //finally send an email receipt
+ $emailValues = $form->_values;
+ // Finally send an email receipt for pay-later scenario (although it might sometimes be caught above!)
+ if ($totalAmount == 0) {
+ // This feels like a bizarre hack as the variable name doesn't seem to be directly connected to it's use in the template.
+ $emailValues['useForMember'] = 0;
+ $emailValues['membership_assign'] = 1;
+ $emailValues['amount'] = 0;
+ }
CRM_Contribute_BAO_ContributionPage::sendMail($contactID,
- $form->_values,
+ $emailValues,
$isTest, FALSE,
$includeFieldTypes
);
*/
protected function processFormSubmission($contactID) {
$isPayLater = $this->_params['is_pay_later'];
+ if (!isset($this->_params['payment_processor_id'])) {
+ // If there is no processor we are using the pay-later manual pseudo-processor.
+ // (note it might make sense to make this a row in the processor table in the db).
+ $this->_params['payment_processor_id'] = 0;
+ }
if (isset($this->_params['payment_processor_id']) && $this->_params['payment_processor_id'] == 0) {
$this->_params['is_pay_later'] = $isPayLater = TRUE;
}