Woocommerce为您的cat / checkout排除类别添加附加费

I'm using a snippet from Woocommerce that adds a surcharge to the total amount of the cart. I'm wondering if there's a way to exclude a certain product category or failing that, a product?

The code I'm using is:

/**
* Add a 1% surcharge to your cart / checkout
* change the $percentage to set the surcharge to a value to suit
* Uses the WooCommerce fees API
*
* Add to theme functions.php
*/
add_action(             
'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
    return;
$percentage = 0.20;
$surcharge = ( $woocommerce->cart->cart_contents_total +        
$woocommerce->cart ) * $percentage;
$woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, '' );
}

function YourUniqueID_add_enqueue_scripts() {
wp_enqueue_script( 'theme_js', trailingslashit(     
get_stylesheet_directory_uri() ) . 'js/theme.js', array( 'jquery' )   
);
}
add_action( 'wp_enqueue_scripts', 'YourUniqueID_add_enqueue_scripts' );

https://wordpress.org/plugins/woocommerce/