Automattic\WooCommerce\StoreApi\Schemas\V1

AbstractSchema::prepare_money_response()protectedWC 1.0

Convert monetary values from WooCommerce to string based integers, using the smallest unit of a currency.

Method of the class: AbstractSchema{}

No Hooks.

Return

String. The new amount.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_money_response( $amount, $decimals, $rounding_mode );
$amount(string|float) (required)
Monetary amount with decimals.
$decimals(int)
Number of decimals the amount is formatted with.
Default: 2
$rounding_mode(int)
Defaults to the PHP_ROUND_HALF_UP constant.
Default: PHP_ROUND_HALF_UP

AbstractSchema::prepare_money_response() code WC 9.4.2

protected function prepare_money_response( $amount, $decimals = 2, $rounding_mode = PHP_ROUND_HALF_UP ) {
	return $this->extend->get_formatter( 'money' )->format(
		$amount,
		[
			'decimals'      => $decimals,
			'rounding_mode' => $rounding_mode,
		]
	);
}