Show Contribution Page receipt text in contribution receipts
authorlarssandergreen <lars@wildsight.ca>
Tue, 5 Sep 2023 19:03:40 +0000 (13:03 -0600)
committerlarssandergreen <lars@wildsight.ca>
Tue, 5 Sep 2023 19:10:58 +0000 (13:10 -0600)
tests/phpunit/CRM/Contribute/ActionMapping/ByTypeTest.php
xml/templates/message_templates/contribution_offline_receipt_html.tpl
xml/templates/message_templates/contribution_offline_receipt_text.tpl

index 6f1cd8e3c0943c678abe473a8c118027553769b1..45fc72ef46e03b5520ed6f7be341d3637c1c9360 100644 (file)
@@ -185,6 +185,7 @@ class CRM_Contribute_ActionMapping_ByTypeTest extends AbstractMappingTest {
       'title' => 'Campaign',
       'name' => 'big_campaign',
     ]);
+    $contributionPage = $this->contributionPageCreate(['receipt_text' => 'Thank you!']);
     $this->ids['Contribution']['alice'] = $this->callAPISuccess('Contribution', 'create', [
       'contact_id' => $this->contacts['alice']['id'],
       'receive_date' => date('Ymd', strtotime($this->targetDate)),
@@ -199,6 +200,7 @@ class CRM_Contribute_ActionMapping_ByTypeTest extends AbstractMappingTest {
       'cancel_date' => '2021-08-09',
       'contribution_status_id' => 1,
       'campaign_id' => $campaignID,
+      'contribution_page_id' => $contributionPage['id'],
       'soft_credit' => [
         '1' => [
           'contact_id' => $this->contacts['carol']['id'],
@@ -321,7 +323,8 @@ class CRM_Contribute_ActionMapping_ByTypeTest extends AbstractMappingTest {
       balance_amount = {contribution.balance_amount}
       campaign_id = {contribution.campaign_id}
       campaign name = {contribution.campaign_id:name}
-      campaign label = {contribution.campaign_id:label}';
+      campaign label = {contribution.campaign_id:label}
+      receipt text = {contribution.contribution_page_id.receipt_text}';
 
     $this->schedule->save();
     $this->callAPISuccess('job', 'send_reminder', []);
@@ -350,6 +353,7 @@ class CRM_Contribute_ActionMapping_ByTypeTest extends AbstractMappingTest {
       'campaign_id = 1',
       'campaign name = big_campaign',
       'campaign label = Campaign',
+      'receipt text = Thank you!',
     ];
     $this->mut->checkMailLog($expected);
 
index afd1b830a5b2eb7bcd8e2f51caecd22cb3baa7ee..a4d76250a2c4a62450b8d4447ec808b57cb0a212 100644 (file)
   <tr>
    <td>
     {assign var="greeting" value="{contact.email_greeting_display}"}{if $greeting}<p>{$greeting},</p>{/if}
-     <p>{ts}Below you will find a receipt for this contribution.{/ts}</p>
+      <p>
+        {if {contribution.contribution_page_id.receipt_text|boolean}}{contribution.contribution_page_id.receipt_text}
+        {else}{ts}Below you will find a receipt for this contribution.{/ts}{/if}
+      </p>
    </td>
   </tr>
   <tr>
index 5a82f5707cf81ba56a12471d3a3bebd8989640b4..4e48d1357cd7545d84f7da16c755ae0b72eff7f6 100644 (file)
@@ -1,6 +1,9 @@
 {assign var="greeting" value="{contact.email_greeting_display}"}{if $greeting}{$greeting},{/if}
 
-{ts}Below you will find a receipt for this contribution.{/ts}
+{if {contribution.contribution_page_id.receipt_text|boolean}}
+{contribution.contribution_page_id.receipt_text}
+{else}{ts}Below you will find a receipt for this contribution.{/ts}
+{/if}
 
 ===========================================================
 {ts}Contribution Information{/ts}