<i id='Ng5HV'><tr id='Ng5HV'><dt id='Ng5HV'><q id='Ng5HV'><span id='Ng5HV'><b id='Ng5HV'><form id='Ng5HV'><ins id='Ng5HV'></ins><ul id='Ng5HV'></ul><sub id='Ng5HV'></sub></form><legend id='Ng5HV'></legend><bdo id='Ng5HV'><pre id='Ng5HV'><center id='Ng5HV'></center></pre></bdo></b><th id='Ng5HV'></th></span></q></dt></tr></i><div id='Ng5HV'><tfoot id='Ng5HV'></tfoot><dl id='Ng5HV'><fieldset id='Ng5HV'></fieldset></dl></div>

    <tfoot id='Ng5HV'></tfoot>

    <small id='Ng5HV'></small><noframes id='Ng5HV'>

    1. <legend id='Ng5HV'><style id='Ng5HV'><dir id='Ng5HV'><q id='Ng5HV'></q></dir></style></legend>
        <bdo id='Ng5HV'></bdo><ul id='Ng5HV'></ul>
    2. 在 WooCommerce 中禁用基于用户国家地理 IP 的所有付款方式

      时间:2024-05-11
      • <bdo id='66uGf'></bdo><ul id='66uGf'></ul>
        <tfoot id='66uGf'></tfoot>
        <i id='66uGf'><tr id='66uGf'><dt id='66uGf'><q id='66uGf'><span id='66uGf'><b id='66uGf'><form id='66uGf'><ins id='66uGf'></ins><ul id='66uGf'></ul><sub id='66uGf'></sub></form><legend id='66uGf'></legend><bdo id='66uGf'><pre id='66uGf'><center id='66uGf'></center></pre></bdo></b><th id='66uGf'></th></span></q></dt></tr></i><div id='66uGf'><tfoot id='66uGf'></tfoot><dl id='66uGf'><fieldset id='66uGf'></fieldset></dl></div>
      • <small id='66uGf'></small><noframes id='66uGf'>

      • <legend id='66uGf'><style id='66uGf'><dir id='66uGf'><q id='66uGf'></q></dir></style></legend>

                  <tbody id='66uGf'></tbody>
                本文介绍了在 WooCommerce 中禁用基于用户国家地理 IP 的所有付款方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在我的 Woocommerce 商店中,我设置了地理定位系统,当地理定位识别除 IT 以外的任何国家/地区时,我想禁用付款方式

                In my Woocommerce shop I set up the geolocation system, when geolocation identifies any country other than IT I would like to disable payment methods

                如果是 IT (geop-ip),请显示付款方式

                If it is IT (geop-ip), show payment methods

                如果是所有其他国家/地区 (geo-ip),请禁用所有付款方式.

                If all other country (geo-ip), disable all payment methods.

                推荐答案

                Woocommerce 已经通过 /class-WC_Geolocation.html" rel="nofollow noreferrer">WC_Geolocation 类,所以你不需要任何额外的插件.

                Woocommerce has already a geolocation Ip feature through WC_Geolocation class, so you don't need any additional plugin.

                这是为除IT"以外的所有国家/地区禁用支付网关的方法.(意大利) 国家代码,基于客户地理定位的 IP 国家/地区:

                Here is the way to disable payment gateways for all countries except "IT" (Italy) country code, based on costumer geolocated IP country:

                // Disabling payment gateways except for the defined country codes based on user IP geolocation country
                add_filter( 'woocommerce_available_payment_gateways', 'geo_country_based_available_payment_gateways', 90, 1 );
                function geo_country_based_available_payment_gateways( $available_gateways ) {
                    // Not in backend (admin)
                    if( is_admin() ) 
                        return $available_gateways;
                
                    // ==> HERE define your country codes
                    $allowed_country_codes = array('IT');
                
                    // Get an instance of the WC_Geolocation object class
                    $geolocation_instance = new WC_Geolocation();
                    // Get user IP
                    $user_ip_address = $geolocation_instance->get_ip_address();
                    // Get geolocated user IP country code.
                    $user_geolocation = $geolocation_instance->geolocate_ip( $user_ip_address );
                
                    // Disable payment gateways for all countries except the allowed defined coutries
                    if ( ! in_array( $user_geolocation['country'], $allowed_country_codes ) )
                        $available_gateways = array();
                
                    return $available_gateways;
                }
                

                代码在您的活动子主题(或活动主题)的functions.php 文件中.经过测试并且可以工作.

                Code goes in functions.php file of your active child theme (or active theme). Tested and works.

                相关:

                • 禁用 WooCommerce 支付网关来宾和特定用户角色
                • 启用基于客户位置的付款方式
                • 隐藏特定的付款方式Woocommerce 中的总重量
                • 根据产品类型隐藏付款方式在 WooCommerce 中

                这篇关于在 WooCommerce 中禁用基于用户国家地理 IP 的所有付款方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

              1. <tfoot id='ECbW4'></tfoot>

                    • <bdo id='ECbW4'></bdo><ul id='ECbW4'></ul>
                      <legend id='ECbW4'><style id='ECbW4'><dir id='ECbW4'><q id='ECbW4'></q></dir></style></legend>
                    • <small id='ECbW4'></small><noframes id='ECbW4'>

                      <i id='ECbW4'><tr id='ECbW4'><dt id='ECbW4'><q id='ECbW4'><span id='ECbW4'><b id='ECbW4'><form id='ECbW4'><ins id='ECbW4'></ins><ul id='ECbW4'></ul><sub id='ECbW4'></sub></form><legend id='ECbW4'></legend><bdo id='ECbW4'><pre id='ECbW4'><center id='ECbW4'></center></pre></bdo></b><th id='ECbW4'></th></span></q></dt></tr></i><div id='ECbW4'><tfoot id='ECbW4'></tfoot><dl id='ECbW4'><fieldset id='ECbW4'></fieldset></dl></div>

                          <tbody id='ECbW4'></tbody>