Automattic\WooCommerce\StoreApi\Schemas\V1
AbstractSchema::prepare_money_response
Convert monetary values from WooCommerce to string based integers, using the smallest unit of a currency.
Method of the class: AbstractSchema{}
No Hooks.
Returns
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() AbstractSchema::prepare money response code WC 11.3.0
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,
]
);
}