Skip to content

Instantly share code, notes, and snippets.

@Frekisunr
Frekisunr / gist:f877d3b0cd63114b4a1efc901ea3eca7
Created July 28, 2016 10:31 — forked from kloon/gist:3972435
WooCommerce disable payment gateways based on customer country
// 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;
}