Created
February 26, 2022 04:56
-
-
Save CmdrMahesh/9a892f1eaf5e91f5ab119c8fa49a3973 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Plugin Name: Conditional Payment Gateway | |
* Description: Conditional Payment Gateway | |
* Version: 1.0 | |
*/ | |
defined( 'ABSPATH' ) || exit; | |
add_action( 'plugins_loaded',function(){ | |
add_filter( 'woocommerce_available_payment_gateways', function($available_gateways) { | |
if ( is_admin() ) return $available_gateways; | |
if ( isset( $available_gateways['bacs'] ) && WC()->customer->get_billing_country() <> 'IN' ) { | |
unset( $available_gateways['bacs'] ); | |
} elseif ( isset( $available_gateways['wc-upi'] ) && WC()->customer->get_billing_country() <> 'IN' ) { | |
unset( $available_gateways['wc-upi'] ); | |
} else { | |
if ( isset( $available_gateways['ppec_paypal'] ) && WC()->customer->get_billing_country() == 'IN' ) { | |
unset( $available_gateways['ppec_paypal'] ); | |
} | |
} | |
return $available_gateways; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment