From 9c91a0ab2fbfe70fa6a19c6a77227ee9a52496fa Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 2 Feb 2024 19:18:49 +1300 Subject: [PATCH] Fix online_receipt template to include receipt text --- CRM/Contribute/BAO/Contribution.php | 1 + CRM/Contribute/BAO/ContributionPage.php | 1 + api/v3/Contribution.php | 11 ++++------- api/v3/MessageTemplate.php | 9 +++------ .../contribution_online_receipt_html.tpl | 8 +++++--- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 48001326b8..71a69631a8 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2668,6 +2668,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac } } else { + $values['modelProps'] = $input['modelProps'] ?? []; return CRM_Contribute_BAO_ContributionPage::sendMail($ids['contact'], $values, $isTest, $returnMessageText); } } diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 9be8c666de..59dcd31af1 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -417,6 +417,7 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio 'tokenContext' => $tokenContext, 'isTest' => $isTest, 'PDFFilename' => 'receipt.pdf', + 'modelProps' => $values['modelProps'] ?? [], ]; if ($returnMessageText) { diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index a20faa3db2..043405d973 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -401,15 +401,12 @@ function civicrm_api3_contribution_sendconfirmation($params) { 'receipt_text', 'pay_later_receipt', 'payment_processor_id', - 'model', ]; $input = array_intersect_key($params, array_flip($allowedParams)); - if (!isset($input['model'])) { - $input['model'] = [ - // Pass through legacy receipt_text. - 'userEnteredText' => $input['tplParams']['receipt_text'] ?? NULL, - ]; - } + $input['modelProps'] = [ + // Pass through legacy receipt_text. + 'userEnteredText' => $params['receipt_text'] ?? NULL, + ]; CRM_Contribute_BAO_Contribution::sendMail($input, [], $params['id']); return []; } diff --git a/api/v3/MessageTemplate.php b/api/v3/MessageTemplate.php index d2683efbc1..42f4c37679 100644 --- a/api/v3/MessageTemplate.php +++ b/api/v3/MessageTemplate.php @@ -107,12 +107,9 @@ function civicrm_api3_message_template_send($params) { unset($params[$field]); } } - if (!isset($params['model'])) { - $params['model'] = [ - // Pass through legacy receipt_text. - 'userEnteredText' => $params['tplParams']['receipt_text'] ?? NULL, - ]; - } + $params['modelProps'] = [ + 'userEnteredText' => $params['tplParams']['receipt_text'] ?? NULL, + ]; if (empty($params['messageTemplateID'])) { if (empty($params['workflow'])) { // Can't use civicrm_api3_verify_mandatory for this because it would give the wrong field names diff --git a/xml/templates/message_templates/contribution_online_receipt_html.tpl b/xml/templates/message_templates/contribution_online_receipt_html.tpl index d148b5218a..d19378254f 100644 --- a/xml/templates/message_templates/contribution_online_receipt_html.tpl +++ b/xml/templates/message_templates/contribution_online_receipt_html.tpl @@ -21,9 +21,11 @@ {assign var="greeting" value="{contact.email_greeting_display}"}{if $greeting}

{$greeting},

{/if} - {if !empty($receipt_text)} -

{$receipt_text|htmlize}

- {/if} + {if $userText} +

{$userText}

+ {elseif {contribution.contribution_page_id.receipt_text|boolean}} +

{contribution.contribution_page_id.receipt_text}

+ {/if} {if $is_pay_later}

{$pay_later_receipt}

{* FIXME: this might be text rather than HTML *} -- 2.25.1