WooCommerce: Set country by default in checkout page

Update (Since WooCommerce 3) This are the woocommerce hooks and code to be used for this purpose for country (and optionally state): add_filter( ‘default_checkout_billing_country’, ‘change_default_checkout_country_and_state’ ); add_filter( ‘default_checkout_shipping_country’, ‘change_default_checkout_country_and_state’ ); add_filter( ‘default_checkout_billing_state’, ‘change_default_checkout_country_and_state’ ); add_filter( ‘default_checkout_shipping_state’, ‘change_default_checkout_country_and_state’ ); function change_default_checkout_country_and_state( $default ) { return null; } Or even shorter: add_filter( ‘default_checkout_billing_country’, ‘__return_null’ ); add_filter( ‘default_checkout_shipping_country’, … Read more

How to get the Country according to a certain IP? [duplicate]

There are two approaches: using an Internet service and using some kind of local list (perhaps wrapped in a library). What you want will depend on what you are building. For services: http://www.hostip.info/use.html (as mentioned by Mark) http://www.team-cymru.org/Services/ip-to-asn.html For lists: http://www.maxmind.com/app/geoip_country (as mentioned by Orion) You could roll your own by downloading the lists from … Read more