Created
June 6, 2022 17:46
Star
You must be signed in to star a gist
Hide Payment gateway based on selected country
This file contains 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