How To Disable Payment Gateways For Some Countries In WooCommerce?

Imagine a scenario where you need to permit PayPal for all nations with the exception of the Unites States. It is difficult to do that without utilizing a php code, except if you utilize the Country Based Payments plugin.

This module enables you to limit or permit installment techniques utilizing a few conditions; for instance, show an installment strategy as indicated by the absolute request, impair an installment technique as indicated by the item being obtained, debilitate an installment technique for a nation, and so forth.

Similarly as with most things, you can do this utilizing code bits or plugins.

[php]

add_filter( ‘woocommerce_available_payment_gateways’, ‘wbcomdesign_payment_gateway_disable_country’ );

function wbcomdesign_payment_gateway_disable_country( $available_gateways ) {
if ( is_admin() ) return $available_gateways;
if ( isset( $available_gateways[‘authorize’] ) && WC()->customer->get_billing_country() <> ‘IN’ ) {
unset( $available_gateways[‘authorize’] );
} else {
if ( isset( $available_gateways[‘paypal’] ) && WC()->customer->get_billing_country() == ‘IN’ ) {
unset( $available_gateways[‘paypal’] );
}
}
return $available_gateways;
}

[/php]

Here, we have added a capacity to the snare woocommerce_available_payment_gateways, which checks the nation code of the nation we are composing the condition for, and incapacitates PayPal for that nation (India for our situation):

Each nation has an alternate code simply like we have utilized “IN” for India here. You can discover the rundown of nation codes toward the finish of this post.

The watchwords/slugs for the default accessible payment gateways are:

Paypal: Paypal
Direct Bank Transfer: Bacs
Cash on Delivery: COD
Cheque: Cheque

Utilizing a plugin to disable payment gateways for certain nations

There are also plugin accessible to incapacitate payment gateways according to the nation of the client. One such plugin is the Country Based Payments plugin. It is a free module that you can use to choose which installment entryway ought to be accessible in which nation. While the module interface is well disposed and clear as crystal, in the event that you need to bar only one nation from an installment door, at that point the path around it is to choose all nations against that installment entryway, and afterward independently unselect the nations which you need to disable that payment gateway for.

 

Leave a Reply

Your email address will not be published. Required fields are marked *