Created
June 7, 2019 02:37
-
-
Save luiseduardobraschi/a07f024ae34eb49b377b16745ffe0d6c to your computer and use it in GitHub Desktop.
Allow coupon only for customers who already have placed orders.
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 = $woocommerce->customer; | |
if ( wc_get_customer_order_count( $customer->get_id() ) < 1 ) { | |
return false; | |
} | |
return $valid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment