Fix event.location token to include supplemental address details, use in event receipts
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 24 Sep 2023 22:17:44 +0000 (11:17 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 28 Sep 2023 21:01:31 +0000 (10:01 +1300)
CRM/Event/Tokens.php
tests/phpunit/CRM/Event/Form/ParticipantTest.php
tests/phpunit/CRM/Utils/TokenConsistencyTest.php
tests/templates/message_templates/event_offline_receipt_html.tpl
xml/templates/message_templates/event_offline_receipt_html.tpl
xml/templates/message_templates/event_offline_receipt_text.tpl
xml/templates/message_templates/event_online_receipt_html.tpl
xml/templates/message_templates/event_online_receipt_text.tpl

index e7b9436f1ceeef5c7e717c779c6f394c987f98fe..6bc9db1aae88d36a3d9272f4e1b9abd96a235cb6 100644 (file)
@@ -177,7 +177,11 @@ class CRM_Event_Tokens extends CRM_Core_EntityTokens {
     if (!Civi::cache('metadata')->has($cacheKey)) {
       $event = Event::get($this->checkPermissions)->addWhere('id', '=', $eventID)
         ->setSelect(array_merge([
+          'loc_block_id.address_id.name',
           'loc_block_id.address_id.street_address',
+          'loc_block_id.address_id.supplemental_address_1',
+          'loc_block_id.address_id.supplemental_address_2',
+          'loc_block_id.address_id.supplemental_address_3',
           'loc_block_id.address_id.city',
           'loc_block_id.address_id.state_province_id:label',
           'loc_block_id.address_id.postal_code',
@@ -206,7 +210,11 @@ class CRM_Event_Tokens extends CRM_Core_EntityTokens {
         ], $this->getExposedFields()))
         ->execute()->first();
       $tokens['location']['text/plain'] = \CRM_Utils_Address::format([
+        'address_name' => $event['loc_block_id.address_id.name'],
         'street_address' => $event['loc_block_id.address_id.street_address'],
+        'supplemental_address_1' => $event['loc_block_id.address_id.supplemental_address_1'],
+        'supplemental_address_2' => $event['loc_block_id.address_id.supplemental_address_2'],
+        'supplemental_address_3' => $event['loc_block_id.address_id.supplemental_address_3'],
         'city' => $event['loc_block_id.address_id.city'],
         'state_province' => $event['loc_block_id.address_id.state_province_id:label'],
         'postal_code' => $event['loc_block_id.address_id.postal_code'],
index 44f17d43b06883bfc09fa4f36dcb02f0e85951f5..12b13ea5cdc343f98cb286d3e4a201a987cf43ca 100644 (file)
@@ -340,11 +340,8 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase {
       'contribution.balance_amount|boolean:::No',
       'contribution.paid_amount|boolean:::Yes',
       '<p>Test event type - 1</p>event.location:8 Baker Street<br />
+Upstairs<br />
 London,',
-      '$location.address.1.display:<div class="location vcard"><span class="adr"><span class="street-address">8 Baker Street</span><br />
-<span class="extended-address">Upstairs</span><br />
-<span class="locality">London</span>,<br />
-</span></div>',
     ]);
 
     $this->callAPISuccess('Email', 'delete', ['id' => $email['id']]);
index 8a69080a6f20b6d72784cf759248dce76e427dd3..6d6bbeddeca711c11f0b96086b6a37ab4642648d 100644 (file)
@@ -715,6 +715,7 @@ event.loc_block_id.email_id.email :event@example.com
 event.loc_block_id.phone_id.phone :456 789
 event.description :event description
 event.location :15 Walton St<br />
+up the road<br />
 Emerald City, Maine 90210<br />
 event.info_url :' . CRM_Utils_System::url('civicrm/event/info', NULL, TRUE) . '&reset=1&id=1
 event.registration_url :' . CRM_Utils_System::url('civicrm/event/register', NULL, TRUE) . '&reset=1&id=1
index 28d58687d434a02ebdb0bf93b8fead480cc68183..927a9481594203d6c63c384e09f7428c7ce3d03a 100644 (file)
@@ -1,2 +1 @@
 event.location:{event.location}
-$location.address.1.display:{$location.address.1.display|smarty:nodefaults|nl2br}
index 79f1b5293b74ee43579520836b754dd0a94cd355..d1f58cc5be83cc2c70d7749816f9cc5fc180e91e 100644 (file)
@@ -67,7 +67,7 @@
      {if {event.is_show_location|boolean}}
       <tr>
        <td colspan="2" {$valueStyle}>
-        {$location.address.1.display|nl2br}
+         {event.location}
        </td>
       </tr>
      {/if}
index 03de2f48bd7cff3551e59ecb90a34fba7b175c9b..62bb7854468ec048ef6a76e17ae2722fb170c693 100644 (file)
@@ -45,7 +45,7 @@
 {/if}
 
 {if !empty($isShowLocation)}
-{$location.address.1.display|strip_tags:false}
+{event.location}
 {/if}{*End of isShowLocation condition*}
 
 {if {event.loc_block_id.phone_id.phone|boolean} || {event.loc_block_id.email_id.email|boolean}}
index fa44cb0588c144f73cd60f8973468a7d128369d4..efb34424cb58faacee13bf6ccb1110b5b18e242c 100644 (file)
@@ -80,7 +80,7 @@
         {if !empty($isShowLocation)}
           <tr>
             <td colspan="2" {$valueStyle}>
-              {$location.address.1.display|nl2br}
+              {event.location}
             </td>
           </tr>
         {/if}
index c17e7f971d3ed25c0fb99c078b94f7bcf74bfedd..e2efd08b9e7111ebb08bd4774b62ebded52924e0 100644 (file)
@@ -55,7 +55,7 @@
 {/if}
 
 {if !empty($isShowLocation)}
-{$location.address.1.display|strip_tags:false}
+{event.location}
 {/if}{*End of isShowLocation condition*}
 
 {if {event.loc_block_id.phone_id.phone|boolean} || {event.loc_block_id.email_id.email|boolean}}