Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
911 views
in Technique[技术] by (71.8m points)

geolocation - Use cloudflare provided country in place of wordpress internal country for pricing of product different for different country

Newbiee here. I am running a woocommerce store with cloudflare active. I am actually interested in product price based on currency, for that plugin to work GEOIP should work.

There is a option in setting where wordpress can detect user country based on IP using its internal max-mind plugin. But since i am running wordpress in a shared enviroment i would rather delicate this work to some other server.

I believe cloudflare send user country in the header. Is there a way i can use that rather than in built geoIP detection?? And if yes any lead , where can i put this code?

PS: Okay so i saw in one forum to add these snippet:

add_filter( 'woocommerce_geolocate_ip', 'sqz_geolocate_cf_ipcountry' );
function sqz_geolocate_cf_ipcountry( $country ) {
    return  $_SERVER[ 'HTTP_CF_IPCOUNTRY' ];
}

Now does this mean first my internal Ip detection run and then it is over-ridden here or this woocommerce_geolocate_ip functionality is replaced by 'sqz_geolocate_cf_ipcountry' method??

I would rather prefer to use country provided by cloudflare and in case if there is some problem(like cloudflare turned off) then use internal maxmind geoip detection.Is it doing that??

question from:https://stackoverflow.com/questions/65833337/use-cloudflare-provided-country-in-place-of-wordpress-internal-country-for-prici

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[5] html - How to create even cell spacing within a

1.4m articles

1.4m replys

5 comments

57.0k users

...