Created
June 6, 2022 17:46
-
-
Save mcnaveen/2e936c999a0259b4fe84697fca494335 to your computer and use it in GitHub Desktop.
Hide Payment gateway based on selected country
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_available_payment_gateways', 'mcnaveen_payment_gateway_based_on_country' ); | |
function mcnaveen_payment_gateway_based_on_country( $available_gateways ) { | |
if ( is_admin() ) return $available_gateways; | |
if ( WC()->customer->get_billing_country() !== 'IN' ) { | |
unset( $available_gateways['wc-razorpay'] ); | |
} else { | |
if ( WC()->customer->get_billing_country() === 'IN' ) { | |
unset( $available_gateways['stripe'] ); | |
} | |
} | |
return $available_gateways; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment