Do the todo (move the function to the trait as suggested
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 12 Aug 2023 22:53:59 +0000 (10:53 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 12 Aug 2023 23:28:20 +0000 (11:28 +1200)
This makes the currency of the contribution available to the template
for other templates - notably offline event receipts

CRM/Contribute/WorkflowMessage/ContributionInvoiceReceipt.php
CRM/Contribute/WorkflowMessage/ContributionTrait.php
Civi/WorkflowMessage/GenericWorkflowMessage.php

index e18907027dc0ed1142664b0dabb6cb321d6810ea..c11d6f32f297739fc54cb8527455318591b43237 100644 (file)
@@ -23,16 +23,4 @@ class CRM_Contribute_WorkflowMessage_ContributionInvoiceReceipt extends GenericW
 
   public const WORKFLOW = 'contribution_invoice_receipt';
 
-  /**
-   * Specify any tokens that should be exported as smarty variables.
-   *
-   * @todo it might be that this should be moved to the trait as we
-   * we work through these.
-   *
-   * @param array $export
-   */
-  protected function exportExtraTokenContext(array &$export): void {
-    $export['smartyTokenAlias']['currency'] = 'contribution.currency';
-  }
-
 }
index 433ef71d672129e1f0971777f65817edde3b921a..81e32f49b42362874eadd9b4cacf540842fe7ac5 100644 (file)
@@ -219,4 +219,14 @@ trait CRM_Contribute_WorkflowMessage_ContributionTrait {
     $export['isShowTax'] = (bool) Civi::settings()->get('invoicing');
   }
 
+  /**
+   * Specify any tokens that should be exported as smarty variables.
+   *
+   * @param array $export
+   */
+  protected function exportExtraTokenContext(array &$export): void {
+    $export['smartyTokenAlias']['currency'] = 'contribution.currency';
+    $export['smartyTokenAlias']['taxTerm'] = 'domain.tax_term';
+  }
+
 }
index efec672168f902f567b307d4fe7ac4b3e948b52b..b2e7148e1959c8682568d5c39c506b5a6dbb8add 100644 (file)
@@ -112,6 +112,8 @@ class GenericWorkflowMessage implements WorkflowMessageInterface {
   protected function exportExtraTokenContext(array &$export): void {
     // Tax term is exposed at the generic level as so many templates use it
     // (e.g. Membership, participant, pledge as well as contributions).
+    // However, these basically now all implement the ContributionTrait so we
+    // can hopefully remove from here (after some checking).
     $export['smartyTokenAlias']['taxTerm'] = 'domain.tax_term';
   }