Skip to main content
Question

How to change the localizedPriceString value to show $15 instead of $15.00

  • May 23, 2023
  • 1 reply
  • 436 views

Forum|alt.badge.img+6
  • Helper
  • 9 replies

Some of our subscription prices are round numbers like $15/yr however when I use the localizedPriceString in the Package class it shows the cents part as 00 e.g. $15.00 I just want the dollar amount if the cents part is 0.

 

I tried modifying package.storeProduct.priceFormatter to hide the fractional part but it didn’t have any effect on the string in the package.localizedPriceString property.

 

Is there some way to just show the localized price without the fractional part via the SDK?

 

Thanks.

This post has been closed for comments

1 reply

kaitlin
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 399 replies
  • May 25, 2023

Hey @mrd,

There’s not a great way to do this via the SDK, we get the prices from the stores and then format them into a string. You could potentially use package.storeProduct.pricePerMonth which is the type NSDecimalNumber (or .price, which is a Decimal) and round to dollar amount before formatting into a string, but this would probably need to be manual for prices that are whole numbers.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings