Skip some product from bogo like free product when applying second time

Exclude specific products from BOGO (Buy One Get One) offers when applying for the second time.

if(!function_exists('woo_discount_rules_skip_discount_for_free_product_method')){
    function woo_discount_rules_skip_discount_for_free_product_method($skip_free_product, $cart_item){
        $_product = $cart_item['data'];
        //Example
        if(!empty($_product)){
            $price = $_product->get_price();
            if($price == 0){
                if(!empty($cart_item['thwepo_options'])) return true;
            }
        }

        return $skip_free_product;
    }
}
add_filter('woo_discount_rules_skip_discount_for_free_product', 'woo_discount_rules_skip_discount_for_free_product_method', 10, 2);