Skip to content

Instantly share code, notes, and snippets.

@apsolut
Created May 12, 2016 10:41
Show Gist options
  • Save apsolut/a2abf9aa6f9bd82998a259c7d3b47baa to your computer and use it in GitHub Desktop.
Save apsolut/a2abf9aa6f9bd82998a259c7d3b47baa to your computer and use it in GitHub Desktop.
woocommerce_available_payment_gateways
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