Skip to content

Price model

Price model consists of the following fields:

  • text: string
  • float: number
  • currency?: string

Price model methods

Price model also has two methods that can be used to manipulate the price.

Price.toFloat

This method allows to return a price in a float format.

Example

const price = new Price({
    text: '$3.21',
    float: 3.21
})

const priceFloat = price.toFloat();

Price.format

This method allows to return a price with a different currency.

Example

const price = new Price({
    text: '$3.21',
    float: 3.21
});

const formattedPrice = price.format('de-DE', 'EUR');