• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wc_format_country_state_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wc_format_country_state_string函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_format_country_state_string函数的具体用法?PHP wc_format_country_state_string怎么用?PHP wc_format_country_state_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wc_format_country_state_string函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: product_by_country

 /**
  * product_by_country.
  *
  * @version 2.5.0
  * @since   2.5.0
  */
 function product_by_country($visible, $product_id)
 {
     // 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'] : '';
     $visible_countries = get_post_meta($product_id, '_' . 'wcj_product_by_country_visible', true);
     if (is_array($visible_countries) && !in_array($country, $visible_countries)) {
         return false;
     }
     return $visible;
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:21,代码来源:class-wcj-product-by-country.php


示例2: wc_get_customer_default_location

/**
 * Get the customer's default location. Filtered, and set to base location or left blank.
 *
 * If cache-busting, this should only be used when 'location' is set in the querystring.
 *
 * @todo should the woocommerce_default_country option be renamed to contain 'base'?
 * @since 2.3.0
 * @return array
 */
function wc_get_customer_default_location()
{
    switch (get_option('woocommerce_default_customer_address')) {
        case 'geolocation_ajax':
        case 'geolocation':
            $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')));
            }
            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 $location;
}
开发者ID:slavic18,项目名称:cats,代码行数:29,代码来源:wc-core-functions.php


示例3: test_wc_format_country_state_string

 /**
  * Test wc_format_country_state_string().
  *
  * @since 2.6.0
  */
 public function test_wc_format_country_state_string()
 {
     // Test with correct values.
     $this->assertEquals(array('country' => 'US', 'state' => 'CA'), wc_format_country_state_string('US:CA'));
     // Test what happens when we pass an incorrect value.
     $this->assertEquals(array('country' => 'US-CA', 'state' => ''), wc_format_country_state_string('US-CA'));
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:12,代码来源:core-functions.php


示例4: wcj_get_user_location

 /**
  * 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;
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:21,代码来源:class-wcj-shortcodes.php


示例5: maybe_exclude_vat

 /**
  * maybe_exclude_vat.
  */
 function maybe_exclude_vat($matched_tax_rates, $tax_class)
 {
     /* wcj_log( explode( '&', $_POST['post_data'] ) ); */
     /* if ( ! isset( $_POST['billing_eu_vat_number'] ) ) return $matched_tax_rates; */
     if ('yes' === get_option('wcj_eu_vat_number_validate', 'yes') && 'yes' === get_option('wcj_eu_vat_number_disable_for_valid', 'yes') && isset($_SESSION['wcj_is_eu_vat_number_valid']) && true === $_SESSION['wcj_is_eu_vat_number_valid'] && isset($_SESSION['wcj_eu_vat_number_to_check'])) {
         $preserve_base_country_check_passed = true;
         if ('yes' === apply_filters('wcj_get_option_filter', 'no', get_option('wcj_eu_vat_number_preserve_in_base_country', 'no'))) {
             $location = wc_get_base_location();
             if (empty($location['country'])) {
                 $location = wc_format_country_state_string(apply_filters('woocommerce_customer_default_location', get_option('woocommerce_default_country')));
             }
             $selected_country = substr($_SESSION['wcj_eu_vat_number_to_check'], 0, 2);
             $preserve_base_country_check_passed = $location['country'] !== $selected_country ? true : false;
         }
         if ($preserve_base_country_check_passed) {
             $modified_matched_tax_rates = array();
             foreach ($matched_tax_rates as $i => $matched_tax_rate) {
                 $matched_tax_rate['rate'] = 0;
                 $modified_matched_tax_rates[$i] = $matched_tax_rate;
             }
             return $modified_matched_tax_rates;
         }
     }
     return $matched_tax_rates;
 }
开发者ID:yarwalker,项目名称:ecobyt,代码行数:28,代码来源:class-wcj-eu-vat-number.php


示例6: wc_get_customer_default_location

/**
 * Get the customer's default location.
 *
 * Filtered, and set to base location or left blank. If cache-busting,
 * this should only be used when 'location' is set in the querystring.
 *
 * @todo should the woocommerce_default_country option be renamed to contain 'base'?
 * @todo deprecate woocommerce_customer_default_location and support an array filter only to cover all cases.
 * @since 2.3.0
 * @return array
 */
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);
}
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:36,代码来源:wc-core-functions.php


示例7: get_debug_info

 /**
 * get_debug_info.
 *
 	function get_debug_info( $args ) {
 		$html = '';
 		if ( 'yes' === get_option( 'wcj_price_by_country_local_enabled' ) ) {
 			$html .= '<p>';
 			$html .= __( 'Price by Country on per Product Basis is enabled.', 'woocommerce-jetpack' );
 			$html .= '</p>';
 		}
 
 		$data = array();
 		$data[] = array( '#', __( 'Countries', 'woocommerce-jetpack' ), __( 'Focus Country', 'woocommerce-jetpack' ), __( 'Regular Price', 'woocommerce-jetpack' ), __( 'Sale Price', 'woocommerce-jetpack' ) );
 		global $product;
 		for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_price_by_country_total_groups_number', 1 ) ); $i++ ) {
 
 			$row = array();
 
 			$row[] = $i;
 
 			$country_exchange_rate_group = get_option( 'wcj_price_by_country_exchange_rate_countries_group_' . $i );
 			$country_exchange_rate_group = str_replace( ' ', '', $country_exchange_rate_group );
 			$row[] = $country_exchange_rate_group;
 
 			$country_exchange_rate_group = explode( ',', $country_exchange_rate_group );
 			$_GET['country'] = $country_exchange_rate_group[0];
 			$row[] = $country_exchange_rate_group[0];
 			$currency_code = wcj_get_currency_symbol( get_option( 'wcj_price_by_country_exchange_rate_currency_group_' . $i ) );
 			$row[] = $product->get_regular_price() . ' ' . $currency_code;
 			$row[] = $product->get_sale_price() . ' ' . $currency_code;
 
 			$data[] = $row;
 		}
 		//$html .= wcj_get_table_html( $data, '', false );
 		$html = wcj_get_table_html( $data, array( 'table_heading_type' => 'vertical', ) );
 		return $html;
 	}
 
 	/**
 * fix_variable_product_price_on_sale.
 *
 	public function fix_variable_product_price_on_sale( $price, $product ) {
 		if ( $product->is_type( 'variable' ) ) {
 			if ( ! $product->is_on_sale() ) {
 				$start_position = strpos( $price, '<del>' );
 				$length = strpos( $price, '</del>' ) - $start_position;
 				// Fixing the price, i.e. removing the sale tags
 				return substr_replace( $price, '', $start_position, $length );
 			}
 		}
 		// No changes
 		return $price;
 	}
 
 	/**
 * get_customer_country_group_id.
 *
 * @version 2.2.6
 */
 public function get_customer_country_group_id()
 {
     // We already know the group - nothing to calculate - return group
     //		if ( null != $this->customer_country_group_id && $this->customer_country_group_id > 0 )
     //			return $this->customer_country_group_id;
     // We've already tried - no country was detected, no need to try again
     /* if ( -1 === $this->customer_country_group_id )
     			return null; */
     if (isset($_GET['country']) && '' != $_GET['country'] && is_super_admin()) {
         $country = $_GET['country'];
     } elseif ('yes' === get_option('wcj_price_by_country_override_on_checkout_with_billing_country', 'no') && is_checkout() && '' != WC()->customer->get_country()) {
         $country = WC()->customer->get_country();
     } else {
         if ('by_ip' === get_option('wcj_price_by_country_customer_country_detection_method', 'by_ip')) {
             // 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'] : null;
         } elseif ('by_user_selection' === get_option('wcj_price_by_country_customer_country_detection_method', 'by_ip')) {
             /* $form_method  = get_option( 'wcj_price_by_country_country_selection_box_method', 'get' );
             			if ( 'get' == $form_method ) {
             				$country = ( isset( $_GET[ 'wcj-country' ] ) ) ? $_GET[ 'wcj-country' ] : null;
             			} else {
             				$country = ( isset( $_POST[ 'wcj-country' ] ) ) ? $_POST[ 'wcj-country' ] : null;
             			} */
             $country = isset($_SESSION['wcj-country']) ? $_SESSION['wcj-country'] : null;
         } elseif ('by_wpml' === get_option('wcj_price_by_country_customer_country_detection_method', 'by_ip')) {
             $country = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : null;
         }
     }
     if (null === $country) {
         $this->customer_country_group_id = -1;
         return null;
     }
     // Get the country group id - go through all the groups, first found group is returned
     for ($i = 1; $i <= apply_filters('wcj_get_option_filter', 1, get_option('wcj_price_by_country_total_groups_number', 1)); $i++) {
         $country_exchange_rate_group = get_option('wcj_price_by_country_exchange_rate_countries_group_' . $i);
         $country_exchange_rate_group = str_replace(' ', '', $country_exchange_rate_group);
//.........这里部分代码省略.........
开发者ID:yarwalker,项目名称:ecobyt,代码行数:101,代码来源:class-wcj-price-by-country-core.php


示例8: maybe_exclude_vat

 function maybe_exclude_vat()
 {
     if ((is_checkout() || is_cart() || defined('WOOCOMMERCE_CHECKOUT') || defined('WOOCOMMERCE_CART') || defined('DOING_AJAX') && DOING_AJAX) && !empty(WC()->customer) && 'yes' === get_option('wcj_eu_vat_number_validate', 'yes') && 'yes' === get_option('wcj_eu_vat_number_disable_for_valid', 'yes') && isset($_SESSION['wcj_is_eu_vat_number_valid']) && true === $_SESSION['wcj_is_eu_vat_number_valid'] && isset($_SESSION['wcj_eu_vat_number_to_check'])) {
         $preserve_base_country_check_passed = true;
         if ('yes' === apply_filters('booster_get_option', 'no', get_option('wcj_eu_vat_number_preserve_in_base_country', 'no'))) {
             $location = wc_get_base_location();
             if (empty($location['country'])) {
                 $location = wc_format_country_state_string(apply_filters('woocommerce_customer_default_location', get_option('woocommerce_default_country')));
             }
             $selected_country = substr($_SESSION['wcj_eu_vat_number_to_check'], 0, 2);
             if ('EL' === $selected_country) {
                 $selected_country = 'GR';
             }
             $preserve_base_country_check_passed = $location['country'] !== $selected_country ? true : false;
         }
         if ($preserve_base_country_check_passed) {
             /* $modified_matched_tax_rates = array();
             			foreach ( $matched_tax_rates as $i => $matched_tax_rate ) {
             				$matched_tax_rate['rate'] = 0;
             				$modified_matched_tax_rates[ $i ] = $matched_tax_rate;
             			}
             			return $modified_matched_tax_rates; */
             WC()->customer->set_is_vat_exempt(true);
         } else {
             WC()->customer->set_is_vat_exempt(false);
         }
     } else {
         if (!empty(WC()->customer)) {
             WC()->customer->set_is_vat_exempt(false);
         }
     }
     //		return $matched_tax_rates;
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:33,代码来源:class-wcj-eu-vat-number.php


示例9: get_customer_country_by_ip

 /**
  * get_customer_country_by_ip.
  *
  * @version 2.5.1
  * @since   2.5.0
  */
 function get_customer_country_by_ip()
 {
     if (class_exists('WC_Geolocation')) {
         // 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')));
         }
         return isset($location['country']) ? $location['country'] : null;
     } else {
         return null;
     }
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:20,代码来源:class-wcj-price-by-country-core.php


示例10: get_customer_country_group_id

 /**
  * get_customer_country_group_id.
  */
 public function get_customer_country_group_id()
 {
     // We already know the group - nothing to calculate - return group
     //		if ( null != $this->customer_country_group_id && $this->customer_country_group_id > 0 )
     //			return $this->customer_country_group_id;
     // We've already tried - no country was detected, no need to try again
     if (-1 === $this->customer_country_group_id) {
         return null;
     }
     if (isset($_GET['country']) && '' != $_GET['country'] && is_super_admin()) {
         $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'] : null;
     }
     if (null === $country) {
         $this->customer_country_group_id = -1;
         return null;
     }
     // Get the country group id - go through all the groups, first found group is returned
     for ($i = 1; $i <= apply_filters('wcj_get_option_filter', 1, get_option('wcj_price_by_country_total_groups_number', 1)); $i++) {
         $country_exchange_rate_group = get_option('wcj_price_by_country_exchange_rate_countries_group_' . $i);
         $country_exchange_rate_group = str_replace(' ', '', $country_exchange_rate_group);
         $country_exchange_rate_group = explode(',', $country_exchange_rate_group);
         if (in_array($country, $country_exchange_rate_group)) {
             $this->customer_country_group_id = $i;
             //wcj_log( 'customer_country_group_id=' . $this->customer_country_group_id );
             return $i;
         }
     }
     // No country group found
     $this->customer_country_group_id = -1;
     return null;
 }
开发者ID:sawan34,项目名称:tanzi,代码行数:42,代码来源:class-wcj-price-by-country-core.php



注:本文中的wc_format_country_state_string函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wc_format_decimal函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_format_content函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap