Below you will find a custom function hooked in wc_get_price_decimals
filter hook, that will set 3 decimals
product prices for a defined product category in product pages, shop page, category and tag archives pages (but not in cart items, or order items).
Here is that code:
add_filter( 'wc_get_price_decimals', 'custom_price_decimals', 10, 1 );
function custom_price_decimals( $decimals ){
global $product;
if( is_a( $product, 'WC_Product' ) ){
// Only for a defined product category
if( has_term( 'clothing', 'product_cat', $product->get_id() ) )
$decimals = 3;
}
return $decimals;
}
The Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested and works.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…