protected function sendReceipts($params, array $participants, $lineItem, $additionalParticipantDetails): array {
$sent = [];
$notSent = [];
- $this->assign('module', 'Event Registration');
$this->assignEventDetailsToTpl($params['event_id'], CRM_Utils_Array::value('role_id', $params), CRM_Utils_Array::value('receipt_text', $params));
- // @todo - this is no longer in core templates as of 5.63
- // we should remove once we have done a 'push upgrade' on addresses - ie advised
- // people to upgrade their templates in an upgrade message, as
- // opposed to just updating unmodified templates.
- $this->assign('isPrimary', (int) $this->_isPaidEvent);
- if ($this->_isPaidEvent) {
- $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
- if (!$this->_mode) {
- if (isset($params['payment_instrument_id'])) {
- $this->assign('paidBy',
- CRM_Utils_Array::value($params['payment_instrument_id'],
- $paymentInstrument
- )
- );
- }
- }
- }
- $this->assign('checkNumber', $params['check_number'] ?? NULL);
if ($this->_mode) {
- $this->assignBillingName($params);
- $this->assign('address', CRM_Utils_Address::getFormattedBillingAddressFieldsFromParameters(
- $this->_params,
- $this->_bltID
- ));
-
$valuesForForm = CRM_Contribute_Form_AbstractEditPayment::formatCreditCardDetails($params);
$this->assignVariables($valuesForForm, ['credit_card_exp_date', 'credit_card_type', 'credit_card_number']);
- $this->assign('is_pay_later', 0);
- }
-
- $this->assign('register_date', $params['register_date']);
- if (isset($params['receive_date'])) {
- $this->assign('receive_date', $params['receive_date']);
}
- $customGroup = [];
- $customFieldFilters = [
- 'ParticipantRole' => $this->getSubmittedValue('role_id'),
- 'ParticipantEventName' => $this->getEventID(),
- 'ParticipantEventType' => $this->getEventValue('event_type_id'),
- ];
- $customFields = CRM_Core_BAO_CustomField::getViewableCustomFields('Participant', $customFieldFilters);
- foreach ($params['custom'] as $fieldID => $values) {
- foreach ($values as $fieldValue) {
- $formattedValue = CRM_Core_BAO_CustomField::displayValue($fieldValue['value'], $fieldID, $participants[0]->id);
- $customGroup[$customFields[$fieldID]['custom_group_id.title']][$customFields[$fieldID]['label']] = str_replace(' ', '', $formattedValue);
- }
- }
- $this->assign('customGroup', $customGroup);
-
$fromEmails = CRM_Event_BAO_Event::getFromEmailIds($this->getEventID());
- foreach ($this->_contactIds as $num => $contactID) {
- // Retrieve the name and email of the contact - this will be the TO for receipt email
- [, $this->_contributorEmail, $this->_toDoNotEmail] = CRM_Contact_BAO_Contact::getContactDetails($contactID);
-
+ foreach ($participants as $num => $participant) {
+ $participantID = $participant->id;
+ $contactID = $participant->contact_id;
+ $key = 'contact_' . $contactID;
+
+ $this->define('Contact', $key, ['id' => $contactID]);
+ if (!$this->lookup($key, 'email_primary.email') || $this->lookup($key, 'do_not_email')) {
+ // try to send emails only if email id is present
+ // and the do-not-email option is not checked for that contact
+ $notSent[] = $contactID;
+ continue;
+ }
$waitStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
$waitingStatus = $waitStatus[$params['status_id']] ?? NULL;
if ($waitingStatus) {