- if (!empty($this->_params['billing_last_name'])) {
- $name .= " {$this->_params['billing_last_name']}";
- }
- $this->assign('billingName', $name);
- }
-
- /**
- * Add the billing address to the contact who paid.
- */
- protected function processBillingAddress() {
- $fields = array();
-
- // set email for primary location.
- $fields['email-Primary'] = 1;
- $this->_params['email-5'] = $this->_params['email-Primary'] = $this->_contributorEmail;
-
- // also add location name to the array
- $this->_params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $this->_params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $this->_params) . ' ' . CRM_Utils_Array::value('billing_last_name', $this->_params);
-
- $this->_params["address_name-{$this->_bltID}"] = trim($this->_params["address_name-{$this->_bltID}"]);
-
- $fields["address_name-{$this->_bltID}"] = 1;
- $fields["email-{$this->_bltID}"] = 1;
-
- list($hasBillingField, $addressParams) = CRM_Contribute_BAO_Contribution::getPaymentProcessorReadyAddressParams($this->_params, $this->_bltID);
-
- $addressParams['preserveDBName'] = TRUE;
- if ($hasBillingField) {
- $addressParams = array_merge($this->_params, $addressParams);
- //here we are setting up the billing contact - if different from the member they are already created
- // but they will get billing details assigned
- CRM_Contact_BAO_Contact::createProfileContact($addressParams, $fields,
- $this->_contributorContactID, NULL, NULL,
- CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactID, 'contact_type')
- );
- }