Disable payment method for currency

To disable specified payment method for specified currency you should add this code to functions.php file in theme folder. This code should work with any currency switcher plugin. In this code PayPal payment method will be disabled for INR currency and Instamojo will be disabled for USD. This code should be changed for you requirements (currency and patment gateway).

add_filter( 'woocommerce_available_payment_gateways', 'studiowp_woocommerce_available_payment_gateways', 100 );
function studiowp_woocommerce_available_payment_gateways( $gateways ) {
	if ( is_checkout() ) {
		if ( get_woocommerce_currency() == 'INR' ) {
			unset( $gateways['paypal'] );
		}
		if ( get_woocommerce_currency() == 'USD' ) {
			unset( $gateways['instamojo'] );
		}
	}
	return $gateways;
}

View the code on Gist.

If you do not use the child theme, remember that changes made to the functions.php file will be overwritten when the theme is updated.

While copying code to functions.php file it is not nessesary to copy <?php opening tag.

If you do not use the child theme, remember that changes made to the functions.php file will be overwritten when the theme is updated.

While copying code to functions.php file it is not nessesary to copy <?php opening tag.

About grola

Passionate about Wordpress and WooCommerce for many years. Author of plugins and short snippets improving Wordpress and WooCommerce.

View all posts by grola →