You have multiple payment gateways in your store. But a lot of Payment gateways are not supported in some countries. So you want to hide then on checkout page.
In WooCommerce there is one hook for it i.e. woocommerce_available_payment_gateways
/**
* Snippet: Disable a Payment Gateway for a country
*/
add_filter( 'woocommerce_available_payment_gateways', 'disable_payment_gateway_based_on_country', 9999 );
function disable_payment_gateway_based_on_country( $available_gateways ) {
if ( is_admin() ) return $available_gateways;
if ( isset( $available_gateways['stripe'] ) && WC()->customer && WC()->customer->get_billing_country() == 'IN' ) {
unset( $available_gateways['stripe'] );
}
return $available_gateways;
}
Leave a Reply