Skip to content
Last updated

WHMCS\View\Formatter\Price

Class

Price Formatter.

Constants

NameDescription
PREFIX
PRICE
SUFFIX

Methods

__construct

public function __construct($price, $currency = null)

Construct price object.

Parameters

TypeNameDescription
float$price
Currency$currency

getValue

public function getValue(): float

The underlying numeric value supporting the format.

Returns float

__toString

public function __toString()

Return the default price format with prefix and suffix.

Returns string

toFull

public function toFull()

Return price with prefix and suffix.

Returns string

toPrefixed

public function toPrefixed()

Return price with prefix only.

Returns string

toSuffixed

public function toSuffixed()

Return price with suffix only.

Returns string

toNumeric

public function toNumeric()

Return numeric price only.

Returns string

format

public function format($format = null, $currency = null)

Format a price in a given format.

Parameters

TypeNameDescription
string|null$format
array|null$currency

Returns string

getCurrency

public function getCurrency()

Return currency property.

Returns Currency\|null

adjustDecimals

public static function adjustDecimals($amount, $currencyCode)

Check the currency code and if it does not support decimal places, round the amount.

Some currencies do not have decimal places as standard.

Parameters

TypeNameDescription
T$amount
string$currencyCode

Returns T\|int

isCycleDisabled

public function isCycleDisabled(): bool