Set all shipping price to 0 when free shipping is applied from discount rules

Set all shipping prices to 0 when free shipping is applied from discount rules.

add_filter( 'woocommerce_package_rates', function($rates) {
    if ( class_exists('\WDRPro\App\Rules\FreeShipping')) {
        $wdr_free_shipping = \WDRPro\App\Rules\FreeShipping::cartHasFreeShipping();
        if (!empty($wdr_free_shipping)) {
            foreach ($rates as $rate) {
                if ($rate->method_id != 'wdr_free_shipping') {
                    $rate->label = $rate->label . ": " . wc_price(0);
                    $rate->cost = 0;
                    unset($rates['wdr_free_shipping']);
                }
            }
        }
    }
    return $rates;
});