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

  • 23 May 2023
  • 1 reply

Badge +5

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?



1 reply

Userlevel 4
Badge +6

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.