The snippet that allow you to configure a list of WooCommerce coupon codes and specify a list of weekday that the coupon is usable.
add_filter( 'woocommerce_coupon_is_valid', 'coupon_week_days_check', 10, 2);
function coupon_week_days_check( $valid, $coupon ) {
$coupon_code = "";
// WooCommerce version compatibility
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
$coupon_code = strtolower($coupon->code); // Older than 3.0
} else {
$coupon_code = strtolower($coupon->get_code()); // 3.0+
}
// 'discountcode' => array of days when the discount code can be used
$coupon_code_wd = array(
'coupon20' => array('Tue', 'Thu'),
);
// if the coupon is one of those to check
if ( isset($coupon_code_wd[$coupon_code]) ) {
// get the coupon days of validity
$valid_days = $coupon_code_wd[$coupon_code_wd[$coupon_code]];
$now_day = date ('D');
// if is not a valid day
if( !in_array($now_day, $valid_days) ) {
$valid = false;
}
}
return $valid;
}