Fix Smarty3 error in online event registration
authoreileen <emcnaughton@wikimedia.org>
Thu, 4 Jan 2024 21:42:34 +0000 (10:42 +1300)
committereileen <emcnaughton@wikimedia.org>
Thu, 4 Jan 2024 21:42:34 +0000 (10:42 +1300)
CRM/Event/WorkflowMessage/ParticipantTrait.php
xml/templates/message_templates/event_online_receipt_html.tpl

index 22c02d19265f342c767c403dd444a0796540fec9..be46e2c807621cc5c33951b4a47a32bc41841dd6 100644 (file)
@@ -50,6 +50,17 @@ trait CRM_Event_WorkflowMessage_ParticipantTrait {
    */
   public $isShowParticipantCount;
 
+  /**
+   * What is the participant count, if 'specifically configured'.
+   *
+   * See getter notes.
+   *
+   * @var bool
+   *
+   * @scope tplParams as participantCount
+   */
+  public $participantCount;
+
   /**
    * @var int
    *
@@ -175,12 +186,28 @@ trait CRM_Event_WorkflowMessage_ParticipantTrait {
    * @throws \CRM_Core_Exception
    */
   public function getIsShowParticipantCount(): bool {
+    return (bool) $this->getParticipantCount();
+  }
+
+  /**
+   * Get the count of participants, where count is used in the line items.
+   *
+   * This might be the case where a line item represents a table of 6 people.
+   *
+   * Where the price field value does not record the participant count we ignore.
+   *
+   * This lack of specifying it is a bit unclear but seems to be 'presumed 1'.
+   * From the templates point of view it is not information to present if not
+   * configured.
+   *
+   * @throws \CRM_Core_Exception
+   */
+  public function getParticipantCount() {
+    $count = 0;
     foreach ($this->getLineItems() as $lineItem) {
-      if ((int) $lineItem['participant_count'] > 1) {
-        return TRUE;
-      }
+      $count += $lineItem['participant_count'];
     }
-    return FALSE;
+    return $count;
   }
 
   /**
index f9cd1b0bc6769d24269bb639ef6cf396ae249ea0..5595786498b152b2c532e584458b078b54029c3b 100644 (file)
                               <th>{ts}Tax Amount{/ts}</th>
                             {/if}
                           <th>{ts}Total{/ts}</th>
-                          {if !empty($pricesetFieldsCount)}
+                          {if $isShowParticipantCount}
                             <th>{ts}Total Participants{/ts}</th>
                           {/if}
                         </tr>
                             <td {$tdStyle}>
                               {$line.line_total_inclusive|crmMoney:$currency}
                             </td>
-                            {if !empty($pricesetFieldsCount)}
+                            {if $isShowParticipantCount}
                               <td {$tdStyle}>{$line.participant_count}</td>
                             {/if}
                           </tr>
                   {contribution.total_amount} {if !empty($hookDiscount.message)}({$hookDiscount.message}){/if}
                 </td>
               </tr>
-              {if !empty($pricesetFieldsCount)}
+              {if $isShowParticipantCount}
                 <tr>
                   <td {$labelStyle}>
                     {ts}Total Participants{/ts}</td>
                   <td {$valueStyle}>
-                    {assign var="count" value= 0}
-                    {foreach from=$lineItem item=pcount}
-                      {assign var="lineItemCount" value=0}
-                      {if $pcount neq 'skip'}
-                        {foreach from=$pcount item=p_count}
-                          {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
-                        {/foreach}
-                        {if $lineItemCount < 1}
-                          {assign var="lineItemCount" value=1}
-                        {/if}
-                        {assign var="count" value=$count+$lineItemCount}
-                      {/if}
-                    {/foreach}
-                    {$count}
+                    {$participantCount}
                   </td>
                 </tr>
               {/if}