I'm looking for a way to give free shipping on all orders based on weekday of the order. So if someone places an order (let's say on Monday) it will give him free shipping no matter what type of order quantity/amount/etc.
I've tried to hook up something from different other tutorials but I can't seem to get the part where I change the free_shipping limit + not sure it works since it's incomplete.
function free_shipping_day( $rates, $package ) {
// valid days
$valid_days = array('Mon');
// current day
$today = date ( 'D' );
// check if it's valid day
if( in_array($today, $valid_day) ){
// clear other shipping methods allow only free
foreach ( $rates as $rate_id => $rate ) {
if ( 'free_shipping' === $rate->method_id ) {
$free[ $rate_id ] = $rate;
}
}
// set free_shipping limit to 0
// show notice
wc_add_notice( __( "Shipping is free today!" ), 'notice');
}
}
add_action('woocommerce_package_rates', 'free_shipping_day');
Any help is very appreciated since I'm kind of stuck with this.