Compatible with Booster for WooCommerce

Ensure compatibility with Booster for WooCommerce.

/**
 * Compatible with booster plugin https://booster.io/shop/booster-for-woocommerce-plus-plugin/
 *
 * Limitations:
 * Works only for Fixed option for Per product settings in Booster settings https://nimb.ws/JPvQwm
 * */
add_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules_v2', 10, 2);

function wcj_price_by_user_role_get_price_compatible_with_discount_rules_v2($return, $_product){
    remove_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules_v2', 10, 2);
    $result = apply_filters('advanced_woo_discount_rules_get_product_discount_price', $return, $_product, 1, $return);
    if($result !== false){
        $return = $result;
    }
    add_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules_v2', 10, 2);
    return $return;
}

add_action('woocommerce_before_calculate_totals', function (){
    remove_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules_v2', 10, 2);
}, 999);
add_action('woocommerce_before_calculate_totals', function (){
    add_filter('wcj_price_by_user_role_get_price', 'wcj_price_by_user_role_get_price_compatible_with_discount_rules_v2', 10, 2);
}, 1001);