Disable payment gateways based on user country geo-ip in Woocommerce

后端 未结 3 2078
被撕碎了的回忆
被撕碎了的回忆 2020-12-20 08:25

In my Woocommerce shop I set up the geolocation system, when geolocation identifies any country other than IT I would like to disable payment methods

If it is IT (ge

3条回答
  •  余生分开走
    2020-12-20 09:25

    In order to find out the user's country you can use a tool like FreeGeoIp, now renamed to Ipstack. You provide the service an IP address and it will tell you the country address the user is likely in (among other information).

    There are two options 1. Using their hosted API (free for 10,000 requests and paid for more than that) 2. Downloading a release from the GitHub link and hosting it yourself

    When you need to know the user's country you can send a HTTP request with the user's IP address to the API and then use that information to enable or disable the payment method.

提交回复
热议问题