Disable Payment Gateway for a Specific Country in WooCommerce

,



If you want to disable payment gateway for a specific country in WooCommerce then you need two options.

  • payment gateway
  • country code 

Here I’m disabling the cod for India. You have to replace "cod" instead of your payment gateway. Have to replace "IN" instead of your decided country code. Place the following code in your functions.php file.

function disable_payment_gateway_for_a_country( $available_gateways ) {
 global $woocommerce;
 if ( isset( $available_gateways['cod'] ) && $woocommerce->customer->get_country() == 'IN' ) 
 {
  unset( $available_gateways['cod'] );
 } 
 return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'disable_payment_gateway_for_a_country' );






Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.