I have come across issue where I want to show 3 decimal places everywhere on the site except cart, checkout and minicart. For that I have added this code to my functions.php file.
add_filter( 'wc_get_price_decimals' , 'custom_price_decimals', 20, 1 );
function custom_price_decimals( $decimals ) {
if( is_checkout() || is_page( 'cart' ) || is_cart() ) {
$decimals = 2;
} else{
$decimals = 3;
}
return $decimals;
}
It shows the results on cart and checkout with 2 decimal places and the rest of the site 3 decimal places. The issue here is that because mini-cart.php isn't on separate page it will show prices with 3 decimals places instead of 2. Can anyone suggest me a workaround because I am not seeing one. Cheers!