What I am trying to do here is hide payments methods, based on the customer country.
Hide bacs and cheque, when the country is different than US.
When the country is US, hide cod payment method (this is working)
I been trying to do this, but it didn't work
Here is the code:
add_filter( 'woocommerce_available_payment_gateways', 'custom_payment_gateway_disable_country' );
function custom_payment_gateway_disable_country( $available_gateways ) {
if ( is_admin() ) return $available_gateways;
if ( isset( $available_gateways['bacs' && 'cheque'] ) && WC()->customer->get_billing_country() <> 'US' ) {
unset( $available_gateways['bacs' && 'cheque'] );
} else {
if ( isset( $available_gateways['cod'] ) && WC()->customer->get_billing_country() == 'US' ) {
unset( $available_gateways['cod'] );
}
}
return $available_gateways;
}
Can someone push me in the right direction? Any help will be appreciated!