Skip to content

Commit

Permalink
Format donation count output in progress bar component (#7209)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Waldstein <[email protected]>
Co-authored-by: Kyle B. Johnson <[email protected]>
  • Loading branch information
3 people authored Dec 10, 2024
1 parent de51672 commit 5d7d4b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/MultiFormGoals/ProgressBar/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,23 @@ public function getDonationCount(): int
return $results->count;
}

/**
* Get formatted number of donations
*
* @unreleased
*/
public function getFormattedDonationCount(): string
{
return give_format_amount(
$this->getDonationCount(),
[
'sanitize' => false,
'decimal' => false,
'currency' => false,
]
);
}

/**
* Get formatted total remaining (ex: $75)
*
Expand Down
5 changes: 4 additions & 1 deletion src/MultiFormGoals/resources/views/progressbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
/**
* Multi-Form Goals block/shortcode template
* Styles for this template are defined in 'blocks/multi-form-goals/common.scss'
*
* @unreleased Format the donation count
*
* @var Give\MultiFormGoals\ProgressBar\Model $this
*/

Expand Down Expand Up @@ -32,7 +35,7 @@
</div>
<div part="stat-count" class="give-progress-bar-block__stat">
<div part="stat-count-value"><?php
echo esc_html($this->getDonationCount()); ?></div>
echo esc_html($this->getFormattedDonationCount()); ?></div>
<div part="stat-count-label"><?php
echo _n('donation', 'donations', $this->getDonationCount(), 'give'); ?></div>
</div>
Expand Down

0 comments on commit 5d7d4b6

Please sign in to comment.