Preview:
add_filter( 'woocommerce_package_rates', 'product_category_hide_shipping_methods', 90, 2 );
function product_category_hide_shipping_methods( $rates, $package ){

    // HERE set your product categories in the array (IDs, slugs or names)
    $categories = array( 204, 558, 840, 879, 903, 904, 1117 );
    $in_cart = false;

    // Loop through each cart item Checking for the defined product categories
    foreach( $package['contents'] as $cart_item ) {
        if ( has_term( $categories, 'product_cat', $cart_item['product_id'] ) ){
            $in_cart = true;
            break;
        }
    }

    if ( $in_cart ) {
        unset( $rates['service_point_shipping_method:15'] ); // shipping method with ID (to find it, see screenshot below)
    }
    return $rates;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter