I am trying to enable free shipping for specific shipping zones (array) on selected days.
I'm using therefore this code:
add_filter( 'woocommerce_shipping_free_shipping_is_available', 'enable_free_shipping_on_selected_days', 10, 3 );
function enable_free_shipping_on_selected_days( $is_available, $package, $shipping_method ) {
$shipping_zones = array('US, Europe');
if ( array_key_exists( $shipping_zones, $rates ) && in_array( date( 'w' ), [ 6, 7 ] ) ) {
return true;
}
return $is_available;
}
But I am getting an error: "Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in.."
Any advice on how to make free shipping available for certain shipping zones on specific days of the week?