I have a woocommerce store based in India and also deals with europe and america. So I want to disable payments options based on customer IP. I have enabled two payment options Payumoney(for india) and Paypal(rest of countries). I am using a snippet that disable selected payment option based on billing country.
function payment_gateway_disable_country( $available_gateways ) {global $woocommerce;
if ( isset( $available_gateways['pumcp'] ) && $woocommerce->customer->get_country() <> 'IN' ) {
unset( $available_gateways['pumcp'] );
} else if ( isset( $available_gateways['paypal'] ) && $woocommerce->customer->get_country() == 'IN' ) {
unset( $available_gateways['paypal'] );
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_country' );
Now problem with this snippet is that if someone orders from USA and choose shipping address to India. Then they have to choose PayUmoney as payment option. And now PayUmoney convenience fee for International payment is around 10%. and vice versa. Yes I know that this snippet works with billing address. So customers will their billing address based on USA and shipping address to India. But sometimes customers fill billing address same of shipping address. Then this snippet causes an issue. So I was thinking to switch payment options based on IP.
Thanx in advance.