WooCommerce
/* Gratis Versand anzeigen und Versandkostenpauschale ausblenden, wenn verfügbar */
 
 function show_only_free_shipping_if_available( $rates )
{
    $free = array();
     foreach ( $rates as $rate_id => $rate )
    {
         if ( 'free_shipping' === $rate->method_id )
        {
              $free[ $rate_id ] = $rate;
              break;
        }
   }
   return ! empty( $free ) ? $free : $rates;
}

add_filter( 'woocommerce_package_rates', 'show_only_free_shipping_if_available', 90 );


// Quelle: https://seom.at/woocommerce-snippets-fuer-die-functions-php-die-dein-webshop-braucht/