Woocommerce Role Based Payment and minimum Subtotal

Currently I’m working on a WC-Project and I’m stucked. With this snippet it’s showing the payment method “bacs” only when the subtotal is over 100. This works fine!

  add_filter( 'woocommerce_available_payment_gateways', 'mmx_remove_bacs', 1 );
function mmx_remove_bacs( $gateways ){
    global $woocommerce;
    if ( $woocommerce->cart->subtotal < 100 ) {
        unset($gateways['bacs']);
    }
    return $gateways;
}

Now this snippet above should only work when a customer is in the Checkout that has the userrole “customer”. For this I have this seperate snippet:

Read More
Function enable_payment( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['bacs'] ) && !current_user_can('customer') ) {
unset( $available_gateways['bacs'] );
} 
return $available_gateways;
}
 add_filter( 'woocommerce_available_payment_gateways', 'enable_payment' );

My question now is, how can I bring this to snippets together, that it works as I wish?

Related posts