php 功能返回woocommerce地理定位
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 功能返回woocommerce地理定位相关的知识,希望对你有一定的参考价值。
/**
* wcj_get_user_location.
*
* @version 2.5.0
*/
function wcj_get_user_location()
{
$country = '';
if (isset($_GET['country']) && '' != $_GET['country'] && wcj_is_user_role('administrator')) {
$country = $_GET['country'];
} else {
// Get the country by IP
$location = WC_Geolocation::geolocate_ip();
// Base fallback
if (empty($location['country'])) {
$location = wc_format_country_state_string(apply_filters('woocommerce_customer_default_location', get_option('woocommerce_default_country')));
}
$country = isset($location['country']) ? $location['country'] : '';
}
return $country;
}
以上是关于php 功能返回woocommerce地理定位的主要内容,如果未能解决你的问题,请参考以下文章