add_filter('woocommerce_package_rates', 'hide_shipping_method_based_on_day_of_the_week', 10, 2);
function hide_shipping_method_based_on_day_of_the_week($rates, $package) {
// Set your default time zone
date_default_timezone_set('Europe/Stockholm');
// Here set your shipping rate Ids
$shipping_rate_ids = ['flat_rate:10', 'free_shipping:14'];
// Check if today is not Friday (5), Saturday (6), or Sunday (7)
if (!in_array(date('N'), [5, 6, 7])) {
foreach ($shipping_rate_ids as $shipping_rate_id) {
if (array_key_exists($shipping_rate_id, $rates)) {
unset($rates[$shipping_rate_id]); // remove it
}
}
}
return $rates;
}