Skip to content

Instantly share code, notes, and snippets.

@benoitmercusot
Last active March 18, 2019 09:12
Show Gist options
  • Save benoitmercusot/9ca6595f8cecd530e3a279887c901ab6 to your computer and use it in GitHub Desktop.
Save benoitmercusot/9ca6595f8cecd530e3a279887c901ab6 to your computer and use it in GitHub Desktop.
<?php
// Le filtre est appliqué dans class-wc-coupon.php
add_filter('woocommerce_coupon_is_valid', 'happy_hour_coupon_validity', 10, 2 );
function happy_hour_coupon_validity( $valid, $coupon ){
if( $coupon->code=='happyhour' && $valid == true ){
if( date('G') > 16 && date('G') < 21 )
return true;
return false;
}
return $valid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment