'id' => ts('Domain ID'),
'description' => ts('Domain Description'),
'now' => ts('Current time/date'),
+ 'tax_term' => ts('Sales tax term (e.g VAT)'),
];
}
$domain->find(TRUE);
}
$tokens = [
- 'name' => $domain->name,
+ 'name' => $domain->name ?? '',
'id' => $domain->id,
- 'description' => $domain->description,
+ 'description' => $domain->description ?? '',
];
$loc = $domain->getLocationValues();
if ($html) {
$email = reset($loc['email']);
$tokens['phone'] = $phone['phone'] ?? '';
$tokens['email'] = $email['email'] ?? '';
+ $tokens['tax_term'] = (string) Civi::settings()->get('tax_term');
Civi::cache('metadata')->set($cacheKey, $tokens);
}
return Civi::cache('metadata')->get($cacheKey);
}
}
+ /**
+ * Define tokens to be exported as smarty values.
+ *
+ * @param array $export
+ */
+ 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).
+ $export['smartyTokenAlias']['taxTerm'] = 'domain.tax_term';
+ }
+
}
/**
* Post test cleanup.
- *
- * @throws \CRM_Core_Exception
*/
public function tearDown():void {
$this->quickCleanup(['civicrm_address', 'civicrm_phone', 'civicrm_im', 'civicrm_website', 'civicrm_openid', 'civicrm_email'], TRUE);
parent::tearDown();
+ Civi::cache('metadata')->clear();
}
- public function testRenderTemplate() {
+ public function testRenderTemplate(): void {
$contactId = $this->individualCreate([
'first_name' => 'Abba',
'last_name' => 'Baab',
$this->assertStringContainsString('<p>Hello testSendTemplate_RenderMode_OpenTemplate Abba Baab!</p>', $messageHtml);
}
- public function testSendTemplate_RenderMode_DefaultTpl() {
+ public function testSendTemplate_RenderMode_DefaultTpl(): void {
CRM_Core_Transaction::create(TRUE)->run(function(CRM_Core_Transaction $tx) {
$tx->rollback();
});
}
- public function testSendTemplate_RenderMode_TokenContext() {
+ public function testSendTemplateRenderModeTokenContext(): void {
CRM_Core_Transaction::create(TRUE)->run(function(CRM_Core_Transaction $tx) {
$tx->rollback();
'{domain.id}' => ts('Domain ID'),
'{domain.description}' => ts('Domain Description'),
'{domain.now}' => 'Current time/date',
+ '{domain.tax_term}' => 'Sales tax term (e.g VAT)',
];
}
* Note that we are creating a logged in user because email goes out from
* that person
*/
- public function testCompleteTransaction() {
+ public function testCompleteTransaction(): void {
$mut = new CiviMailUtils($this, TRUE);
+ Civi::settings()->set('tax_term', 'GST');
$this->swapMessageTemplateForTestTemplate();
$this->createLoggedInUser();
$params = array_merge($this->_params, ['contribution_status_id' => 2]);
"receipt_date:::\n",
'title:::Contribution',
'contributionStatus:::Completed',
+ 'taxTerm:::GST',
]);
$mut->stop();
$this->revertTemplateToReservedTemplate();
{if !empty($priceset)}
priceset:::{$priceset}
{/if}
- {if !empty($taxTerm)}
taxTerm:::{$taxTerm}
- {/if}
{if !empty($pcpBlock)}
pcpBlock:::{$pcpBlock}
pcp_display_in_roll:::{$pcp_display_in_roll}
{if !empty($isBillingAddressRequiredForPayLater)}
isBillingAddressRequiredForPayLater:::{$isBillingAddressRequiredForPayLater}
{/if}
- {if !empty($billingName)}
billingName:::{$billingName}
address:::{$address}
- {/if}
{if !empty($credit_card_type)}
credit_card_type:::{$credit_card_type}
credit_card_number:::{$credit_card_number}