Note that WC_ROUNDING_PRECISION
constant is set to 6
in WC_Woocommerce
define_constants() method.
That means that WooCommerce Tax calculation precision is already set on 6 decimals.
Tax calculation precision are based on wc_get_rounding_precision()
core function used in WC_Tax
Class:
function wc_get_rounding_precision() {
$precision = wc_get_price_decimals() + 2;
if ( absint( WC_ROUNDING_PRECISION ) > $precision ) {
$precision = absint( WC_ROUNDING_PRECISION );
}
return $precision;
}
As you can see WC_ROUNDING_PRECISION
constant is prioritized if the displayed price decimal value + 2 is smaller than WC_ROUNDING_PRECISION
constant. But as you want to keep displayed prices with 2 decimals, this requires something else.
So you should not increase displayed price decimals and not use wc_price_args
or/and wc_get_price_decimals
hooks, to increase precision in tax calculation.
If precision of 6 decimals is not enough and you want to get more precision:
How to get more precision on Tax calculations?
The best way to get more precision on tax calculations and keep displayed prices with 2 decimals is to edit WordPress wp_config.php file and add the following lines (where you can increase WC_ROUNDING_PRECISION
constant value as you like, here the value is set to 8 for example):
// Change WooCommerce rounding precision
define('WC_ROUNDING_PRECISION', 8);
This will change WC_ROUNDING_PRECISION
constant without affecting displayed price decimals.