Fix online_receipt template to include receipt text
authoreileen <emcnaughton@wikimedia.org>
Fri, 2 Feb 2024 06:18:49 +0000 (19:18 +1300)
committereileen <emcnaughton@wikimedia.org>
Sat, 3 Feb 2024 08:40:50 +0000 (21:40 +1300)
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/ContributionPage.php
api/v3/Contribution.php
api/v3/MessageTemplate.php
xml/templates/message_templates/contribution_online_receipt_html.tpl

index 48001326b8c01398cb25752ae5ab1b609dbea280..71a69631a81add867ca8a10b6c4385be68ce6464 100644 (file)
@@ -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);
       }
     }
index 9be8c666de80a0b2f76e72df6d2ad6b8c9aaa54e..59dcd31af179fa0d2460ae175a2c5f52098a7877 100644 (file)
@@ -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) {
index a20faa3db2ee696ff4b1343ceaba8aa5277f63e6..043405d973cf0f435a301452506e9095c175d5e1 100644 (file)
@@ -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 [];
 }
index d2683efbc13a5f4335356bc5f2edb219cedcf130..42f4c37679e2e325a8a906c63d30c30d5c56dad0 100644 (file)
@@ -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
index d148b5218a278c67bd58ac93b6cf4db5bca1cee6..d19378254fffdce13a6efc1b02147af93faabd8e 100644 (file)
   <tr>
    <td>
      {assign var="greeting" value="{contact.email_greeting_display}"}{if $greeting}<p>{$greeting},</p>{/if}
-    {if !empty($receipt_text)}
-     <p>{$receipt_text|htmlize}</p>
-    {/if}
+     {if $userText}
+       <p>{$userText}</p>
+     {elseif {contribution.contribution_page_id.receipt_text|boolean}}
+       <p>{contribution.contribution_page_id.receipt_text}</p>
+     {/if}
 
     {if $is_pay_later}
      <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}