Created
May 12, 2016 10:41
-
-
Save apsolut/a2abf9aa6f9bd82998a259c7d3b47baa to your computer and use it in GitHub Desktop.
woocommerce_available_payment_gateways
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
function decom_paypal_disable_manager( $available_gateways ) { | |
global $woocommerce; | |
$user = wp_get_current_user(); | |
if ( isset( $available_gateways['cheque'] ) && (in_array( 'customer', $user->roles ) || in_array( 'client', $user->roles) || in_array( 'klingon', $user->roles) )) { | |
//unset( $available_gateways['cheque'] ); | |
} | |
else if ( isset( $available_gateways['paypal'] ) && ( in_array( 'wholesale', $user->roles ) || in_array( 'retailer', $user->roles) ) ) { | |
unset( $available_gateways['paypal'] ); | |
} | |
else if ( !is_user_logged_in() ) { | |
unset( $available_gateways['cheque'] ); | |
} | |
return $available_gateways; | |
} | |
add_filter( 'woocommerce_available_payment_gateways', 'decom_paypal_disable_manager' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment