From: eileen Date: Thu, 4 Jan 2024 21:42:34 +0000 (+1300) Subject: Fix Smarty3 error in online event registration X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cff69084631478de9744688ca06abeff15c3db33;p=civicrm-core.git Fix Smarty3 error in online event registration --- diff --git a/CRM/Event/WorkflowMessage/ParticipantTrait.php b/CRM/Event/WorkflowMessage/ParticipantTrait.php index 22c02d1926..be46e2c807 100644 --- a/CRM/Event/WorkflowMessage/ParticipantTrait.php +++ b/CRM/Event/WorkflowMessage/ParticipantTrait.php @@ -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; } /** diff --git a/xml/templates/message_templates/event_online_receipt_html.tpl b/xml/templates/message_templates/event_online_receipt_html.tpl index f9cd1b0bc6..5595786498 100644 --- a/xml/templates/message_templates/event_online_receipt_html.tpl +++ b/xml/templates/message_templates/event_online_receipt_html.tpl @@ -206,7 +206,7 @@ {ts}Tax Amount{/ts} {/if} {ts}Total{/ts} - {if !empty($pricesetFieldsCount)} + {if $isShowParticipantCount} {ts}Total Participants{/ts} {/if} @@ -228,7 +228,7 @@ {$line.line_total_inclusive|crmMoney:$currency} - {if !empty($pricesetFieldsCount)} + {if $isShowParticipantCount} {$line.participant_count} {/if} @@ -300,25 +300,12 @@ {contribution.total_amount} {if !empty($hookDiscount.message)}({$hookDiscount.message}){/if} - {if !empty($pricesetFieldsCount)} + {if $isShowParticipantCount} {ts}Total Participants{/ts} - {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} {/if}