wc_round_tax_total( double $value, int $precision = null )
Round a tax amount.
Description Description
Parameters Parameters
- $value
-
(Required) Amount to round.
- $precision
-
(Optional) DP to round. Defaults to wc_get_price_decimals.
Default value: null
Return Return
(float)
Source Source
File: includes/wc-formatting-functions.php
function wc_round_tax_total( $value, $precision = null ) {
$precision = is_null( $precision ) ? wc_get_price_decimals() : intval( $precision );
if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
$rounded_tax = round( $value, $precision, wc_get_tax_rounding_mode() ); // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctionParameters.round_modeFound
} elseif ( 2 === wc_get_tax_rounding_mode() ) {
$rounded_tax = wc_legacy_round_half_down( $value, $precision );
} else {
$rounded_tax = round( $value, $precision );
}
return apply_filters( 'wc_round_tax_total', $rounded_tax, $value, $precision, WC_TAX_ROUNDING_MODE );
}