Skip an item from calculating subtotal for price rules

Skip an item from subtotal calculation for price rules.

function woo_discount_rules_skip_item_to_calculate_subtotal_for_price_rules_free_products($include_item, $cart_item, $rule){
    $product_ids_to_exclude = array(10, 24);//ENTER THE PRODUCT IDS to exclude from calculating subtotal
    if(isset($cart_item['data']) && !empty($cart_item['data'])){
        $_product = $cart_item['data'];
        $product_id = $_product->get_id();
        if(in_array($product_id, $product_ids_to_exclude)){
            $include_item = false;
        }
    }
    return $include_item;
}
add_filter('woo_discount_rules_skip_item_to_calculate_subtotal_for_price_rules', 'woo_discount_rules_skip_item_to_calculate_subtotal_for_price_rules_free_products', 10, 3);