Created
September 11, 2019 16:35
-
-
Save luiseduardobraschi/1a25f9dd01a4b8033e7d1ee30d0ba29b to your computer and use it in GitHub Desktop.
[WooCommerce BR] Restrict coupon from being used bt its author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('woocommerce_coupon_is_valid', 'wcbr_coupon_is_valid', 10, 2); | |
function wcbr_coupon_is_valid( $valid, $coupon ) { | |
global $woocommerce; | |
$customer_id = $woocommerce->customer->get_id(); | |
$coupon_author_id = get_post_field( 'post_author', $coupon->get_id() ); | |
if ( $customer_id === $coupon_author_id ) { | |
return false; | |
} | |
return $valid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment