Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format donation count output in progress bar component #7209

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

DevinWalker
Copy link
Member

Resolves #7208

Description

This resolves the issue with the "Donation" count total not being formatted properly.

I'm using give_format_amount() for this, even though it's a total, not an amount because I didn't see any other generic non-currency-based way to do it. This seems to work fine, though.

Affects

Progress bar component with donation counts.

Visuals

Before

2024-01-29_10-54-15

After
2024-01-29_11-43-53

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

This commit changes the return type of the getDonationCount function from int to string. It also introduces formatting, specifically disabling sanitization, decimal, and currency formatting options for the returned count, using the give_format_amount function.
The getDonationCount method now returns a formatted donation count string, instead of an int. A new method, getFormattedDonationCount, has been introduced to apply the give_format_amount function, turning off sanitization, decimal, and currency formatting. This results in a cleaner display of donation counts in the progress bar.
@DevinWalker DevinWalker changed the title Update getDonationCount return type and formatting Format donation count output in progress bar component Jan 29, 2024
@@ -32,7 +32,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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could simplify this by using number_format directly instead of give_format_amount:

Suggested change
echo esc_html($this->getFormattedDonationCount()); ?></div>
echo esc_html(number_format($this->getDonationCount())); ?></div>
Screenshot 2024-02-01 at 4 08 35 PM

Copy link

This PR is stale because it has been open 45 days with no activity. Stale PRs will NOT be automatically closed.

@github-actions github-actions bot added the Stale label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-form goal block should have formatted donation number total
2 participants