Skip to content

Instantly share code, notes, and snippets.

@optimuswebsites
Forked from kloon/gist:3972435
Created April 30, 2014 21:41
Show Gist options
  • Save optimuswebsites/301d2cae96f8feeb7c8a to your computer and use it in GitHub Desktop.
Save optimuswebsites/301d2cae96f8feeb7c8a to your computer and use it in GitHub Desktop.
// Disable gateway based on country
function payment_gateway_disable_country( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['ccavenue'] ) && $woocommerce->customer->get_country() <> 'IN' ) {
unset( $available_gateways['ccavenue'] );
} else if ( isset( $available_gateways['paypal'] ) && $woocommerce->customer->get_country() == 'IN' ) {
unset( $available_gateways['paypal'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_country' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment