Custom bundle compatibility for WooCommerce Product Bundles

Ensure compatibility with Custom Bundles for WooCommerce Product Bundles.

// Exclude bundle parent product quantity if is not BOGO discount
// Exclude bundle child product quantity if is BOGO discount
// Exclude bundle child products from apply discounts
// for WooCommerce Product Bundles
add_filter('advanced_woo_discount_rules_calculate_discount_for_cart_item', function ($calculate_discount, $cart_item){
    if(isset($cart_item['bundled_item_id']) && !empty($cart_item['bundled_item_id'])){
        $calculate_discount = false;
    }
    return $calculate_discount;
}, 100, 2);
add_filter('advanced_woo_discount_rules_include_cart_item_to_count_quantity', function($take_count, $cart_item, $type){
    if(
        (isset($cart_item['bundled_items']) && !empty($cart_item['bundled_items']) && $type != 'bogo_stock_check')
        || (isset($cart_item['bundled_item_id']) && !empty($cart_item['bundled_item_id']) && $type == 'bogo_stock_check')
    ) {
        $take_count = false;
    }
    return $take_count;
}, 100, 3);
add_filter('advanced_woo_discount_rules_process_cart_item_for_cheapest_rule', function($calculate_discount, $cart_item){
    if(isset($cart_item['bundled_item_id']) && !empty($cart_item['bundled_item_id'])){
        $calculate_discount = false;
    }
    return $calculate_discount;
}, 100, 2);