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

Add-Ons: Round dynamically generated add-on monthly price #95369

Merged
merged 6 commits into from
Oct 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check if cost is an integer or float
  • Loading branch information
jeyip committed Oct 15, 2024
commit 7dd441fc1af45266813194398f24fce072480622
6 changes: 3 additions & 3 deletions packages/data-stores/src/add-ons/hooks/use-add-on-prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ const useAddOnPrices = ( productSlug: ProductsList.StoreProductSlug, quantity?:
//
// The ideal answer is to trace the root cause of the recalculations and prevent them, but after
// taking a cursory look, it seems as if this will require deeper investigation. For now, because
// we are always working with smallest currency units for add-ons, we explicitly round the add-on
// monthly price to suppress the warnings ( something that was already happening in the library ).
let monthlyPrice = Math.round( cost / 12 );
// we are always working with smallest currency units for add-ons, we explicitly round decimal add-on
// monthly prices to suppress the warnings ( something that was already happening in the library ).
let monthlyPrice = Number.isInteger( cost ) ? cost : Math.round( cost / 12 );
let yearlyPrice = cost;

if ( product?.term === 'month' ) {
Expand Down