Last active
May 14, 2020 19:11
-
-
Save deivamagalhaes/e766f35a19995b80ccf1b776aa3a5e92 to your computer and use it in GitHub Desktop.
Hide checkout add-on from members - replace my-addon with the name of your add-on
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_checkout_add_on_get_enabled', function( $value, $checkout_add_on ) { | |
// bail if Memberships is not active | |
if ( ! function_exists( 'wc_memberships_is_user_member' ) ) { | |
return $value; | |
} | |
// if you have more than one checkout add-on, check if it is the one you want to hide | |
if ( 'my-addon' === $checkout_add_on->get_name() ) { | |
// return false if user is member of any plan (if you have more plans, you will want to set the 2nd param) | |
$value = ! wc_memberships_is_user_member(); | |
} | |
return $value; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment