تابع wc_get_customer_default_location دریافت موقعیت پیشفرض مشتری (کاربر)

تابع ووکامرسی wc_get_customer_default_location – دریافت موقعیت پیشفرض مشتری (کاربر)
Syntax – سینتکس
(array) wc_get_customer_default_location();
Usage – نحوه استفاده
if ( !function_exists( 'wc_get_customer_default_location' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-core-functions.php';
}
// NOTICE! Understand what this does before running.
$result = wc_get_customer_default_location();
Defined – محل تعریف
/includes/wc-core-functions.php
function wc_get_customer_default_location() {
$location = array();
switch ( get_option( 'woocommerce_default_customer_address' ) ) {
case 'geolocation_ajax' :
case 'geolocation' :
// Exclude common bots from geolocation by user agent.
$ua = wc_get_user_agent();
if ( ! strstr( $ua, 'bot' ) && ! strstr( $ua, 'spider' ) && ! strstr( $ua, 'crawl' ) ) {
$location = WC_Geolocation::geolocate_ip( '', true, false );
}
// Base fallback.
if ( empty( $location['country'] ) ) {
$location = wc_format_country_state_string( apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) ) );
}
break;
case 'base' :
$location = wc_format_country_state_string( apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) ) );
break;
default :
$location = wc_format_country_state_string( apply_filters( 'woocommerce_customer_default_location', '' ) );
break;
}
return apply_filters( 'woocommerce_customer_default_location_array', $location );
}
versions – نسخه ها
از نسخه : 2.3.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر