add_filter( 'formatted_woocommerce_price', 'dcwd_remove_zero_decimals', 10, 5 );
function dcwd_remove_zero_decimals( $formatted_price, $price, $decimal_places, $decimal_separator, $thousand_separator ) {
/*
// Leave decimals in on single product page.
if ( is_product() ) {
return $formatted_price;
}
*/
if ( $price - intval( $price ) == 0 ) {
// Format units, including thousands separator if necessary.
return $unit = number_format( intval( $price ), 0, $decimal_separator, $thousand_separator );
}
else {
return $formatted_price;
}
}