Skip to content

WP checkout cannot handle pricing above $999 #860

@itmaybejj

Description

@itmaybejj

🐞 bug report

Behavior:

  • What is the issue? (*)
    I am trying to set up an app for sale with enterprise/multisite tiers (my typical user has 500+ sites). But if any tier has an annual price with a comma ($1,000+), the React app that generates the upgrade interface chokes on the comma separator and outputs $1.58:
Image

Versions: (*)

  • Freemius SDK Version: 2.13.1
  • WordPress Version: 7.0
  • PHP Version: 8.4.18

Plugin / Theme: (*)

  • Name: Editoria11y
  • Slug: editoria11y-accessibility-checker (Freemius version still under development)
  • Freemius ID: 26217

Problem code:

// l = N(o.getMonthlyAmount(D), "en-US")
//   where N = (e,t) => e.toLocaleString(t, {maximumFractionDigits:2})
// So for 19999/12 = 1666.5833..., l becomes "1,666.58"

if (l) {
    const e = l.split(".");          // ["1,666", "58"]
    g = N(parseInt(e[0], 10));       // parseInt("1,666",10) === 1 → g = "1"
    h = L(e[1]);                     // L("58") = "58"
}
// Rendered as $<g>.<h> → "$1.58"

To fix: split on the locale separator or do Math.floor(x) / Math.round((x%1)*100) to get your decimal instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions