Automattic\WooCommerce\StoreApi\Formatters
MoneyFormatter::format()
Format a given value and return the result.
Method of the class: MoneyFormatter{}
No Hooks.
Return
Mixed
.
Usage
$MoneyFormatter = new MoneyFormatter(); $MoneyFormatter->format( $value, $options );
- $value(mixed) (required)
- Value to format.
- $options(array)
- Options that influence the formatting.
Default: []
MoneyFormatter::format() MoneyFormatter::format code WC 8.7.0
public function format( $value, array $options = [] ) { $options = wp_parse_args( $options, [ 'decimals' => wc_get_price_decimals(), 'rounding_mode' => PHP_ROUND_HALF_UP, ] ); return (string) intval( round( ( (float) wc_format_decimal( $value ) ) * ( 10 ** absint( $options['decimals'] ) ), 0, absint( $options['rounding_mode'] ) ) ); }