wc_add_number_precision()
Add precision to a number and return a number.
No Hooks.
Return
Int|float
.
Usage
wc_add_number_precision( $value, $round );
- $value(float) (required)
- Number to add precision to.
- $round(true|false)
- If should round after adding precision.
Default: true
Changelog
Since 3.2.0 | Introduced. |
wc_add_number_precision() wc add number precision code WC 7.3.0
function wc_add_number_precision( float $value, bool $round = true ) { $cent_precision = pow( 10, wc_get_price_decimals() ); $value = $value * $cent_precision; return $round ? NumberUtil::round( $value, wc_get_rounding_precision() - wc_get_price_decimals() ) : $value; }