Skip to content

Commit

Permalink
Search: Fix paid requests localization in upsell (#38946)
Browse files Browse the repository at this point in the history
* Update the number formatting to use the correct locale

* Use getUserLocale to get the locale

---------

Co-authored-by: Jason Moon <noreply@jsnmoon.com>
  • Loading branch information
d-alleyne and jsnmoon authored Aug 27, 2024
1 parent 5faaff4 commit 5f324e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Search: Use the user's locale when formatting request limits.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Container,
Col,
PricingCard,
getUserLocale,
AdminSectionHero,
ProductPrice,
PricingTable,
Expand Down Expand Up @@ -155,7 +156,7 @@ const OldPricingComponent = ( { sendToCart } ) => {

const NewPricingComponent = ( { sendToCartPaid, sendToCartFree } ) => {
const siteDomain = useSelect( select => select( STORE_ID ).getCalypsoSlug(), [] );

const localeSlug = getUserLocale();
const priceBefore = useSelect( select => select( STORE_ID ).getPriceBefore() / 12, [] );
const priceAfter = useSelect( select => select( STORE_ID ).getPriceAfter() / 12, [] );
const priceCurrencyCode = useSelect( select => select( STORE_ID ).getPriceCurrencyCode(), [] );
Expand All @@ -166,7 +167,7 @@ const NewPricingComponent = ( { sendToCartPaid, sendToCartFree } ) => {
const { hasConnectionError } = useConnectionErrorNotice();

const paidRecordsLimitRaw = useSelect( select => select( STORE_ID ).getPaidRecordsLimit(), [] );
const paidRecordsLimit = new Intl.NumberFormat( 'en-US', {
const paidRecordsLimit = new Intl.NumberFormat( localeSlug, {
notation: 'compact',
compactDisplay: 'short',
} ).format( paidRecordsLimitRaw );
Expand All @@ -176,14 +177,14 @@ const NewPricingComponent = ( { sendToCartPaid, sendToCartFree } ) => {
const unlimitedText = __( 'Unlimited', 'jetpack-search-pkg' );
const paidRequestsLimit = hasUnlimitedRequests
? unlimitedText
: new Intl.NumberFormat( 'en-US', {
: new Intl.NumberFormat( localeSlug, {
notation: 'compact',
compactDisplay: 'short',
} ).format( paidRequestsLimitRaw );

const unitPrice = useSelect( select => select( STORE_ID ).getAdditionalUnitPrice(), [] );
const unitQuantityRaw = useSelect( select => select( STORE_ID ).getAdditionalUnitQuantity(), [] );
const unitQuantity = new Intl.NumberFormat( 'en-US', {
const unitQuantity = new Intl.NumberFormat( localeSlug, {
notation: 'compact',
compactDisplay: 'short',
} ).format( unitQuantityRaw );
Expand Down

0 comments on commit 5f324e9

Please sign in to comment.