wc_round_discount( double $value, int $precision )

Round discount.


Description Description


Parameters Parameters

$value

(Required) Amount to round.

$precision

(Required) DP to round.


Top ↑

Return Return

(float)


Top ↑

Source Source

File: includes/wc-core-functions.php

function wc_round_discount( $value, $precision ) {
	if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
		return round( $value, $precision, WC_DISCOUNT_ROUNDING_MODE ); // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctionParameters.round_modeFound
	}

	if ( 2 === WC_DISCOUNT_ROUNDING_MODE ) {
		return wc_legacy_round_half_down( $value, $precision );
	}

	return round( $value, $precision );
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.