Formats a number in typical price-style.

This calls internally format_number(...) with predefined settings.

This function allows more fraction-control as the standard PHP / twig number_format(...) function.


Syntax

format_number( $number, ?string $rplcFracZero = null): string

  • $number - int|float|string|null
    The number to format.

  • $rplcFracZero
    Optional String that will be appended if no fractions occur. Use this (",-") e.g. for price-formatting:  49.00 =>  49,-


Examples

You can use the "zero-fraction-replace"-parameter to beautify outputs to like:  49,-

{{ hublify.format_price( 49 }}          =>    49,00

{{ hublify.format_price( 49 , ",-" }}          =>    49,-
{{ hublify.format_price( 49.5 , ",-" }}        =>    49,50