From c5b39419ac33428730800399b80f37299976933f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 13 Aug 2023 10:53:59 +1200 Subject: [PATCH] Do the todo (move the function to the trait as suggested This makes the currency of the contribution available to the template for other templates - notably offline event receipts --- .../WorkflowMessage/ContributionInvoiceReceipt.php | 12 ------------ CRM/Contribute/WorkflowMessage/ContributionTrait.php | 10 ++++++++++ Civi/WorkflowMessage/GenericWorkflowMessage.php | 2 ++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CRM/Contribute/WorkflowMessage/ContributionInvoiceReceipt.php b/CRM/Contribute/WorkflowMessage/ContributionInvoiceReceipt.php index e18907027dc0..c11d6f32f297 100644 --- a/CRM/Contribute/WorkflowMessage/ContributionInvoiceReceipt.php +++ b/CRM/Contribute/WorkflowMessage/ContributionInvoiceReceipt.php @@ -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'; - } - } diff --git a/CRM/Contribute/WorkflowMessage/ContributionTrait.php b/CRM/Contribute/WorkflowMessage/ContributionTrait.php index 433ef71d6721..81e32f49b423 100644 --- a/CRM/Contribute/WorkflowMessage/ContributionTrait.php +++ b/CRM/Contribute/WorkflowMessage/ContributionTrait.php @@ -219,4 +219,14 @@ protected function exportExtraTplParams(array &$export): void { $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'; + } + } diff --git a/Civi/WorkflowMessage/GenericWorkflowMessage.php b/Civi/WorkflowMessage/GenericWorkflowMessage.php index efec672168f9..b2e7148e1959 100644 --- a/Civi/WorkflowMessage/GenericWorkflowMessage.php +++ b/Civi/WorkflowMessage/GenericWorkflowMessage.php @@ -112,6 +112,8 @@ protected function validateExtra_contact(array &$errors) { 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'; }