久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 WooCommerce 中禁用所有基于用戶國家地理 IP 的支

Disable all payment methods based on user country geo-ip in WooCommerce(在 WooCommerce 中禁用所有基于用戶國家地理 IP 的支付方式)
本文介紹了在 WooCommerce 中禁用所有基于用戶國家地理 IP 的支付方式的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

在我的 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 的支付方式的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 日本精品一区二区三区在线观看 | 高清欧美性猛交xxxx黑人猛交 | 99这里只有精品视频 | 91视视频在线观看入口直接观看 | 亚洲成人一区 | 草草影院ccyy | 日韩av中文 | 午夜久久久久 | 免费啪啪| 午夜小电影 | 久久久免费观看视频 | 精品免费国产一区二区三区 | 99热这里都是精品 | 午夜影院视频 | 精品成人佐山爱一区二区 | 中文字幕视频一区二区 | 久久国产精品视频免费看 | 久久久久久国产精品免费免费 | 精品国产乱码久久久久久牛牛 | av喷水| 正在播放一区二区 | 国产精品精品久久久 | 欧美性jizz18性欧美 | 欧美视频在线一区 | 国产一区二区毛片 | 日本手机看片 | 久久里面有精品 | 91成人免费看片 | 中文字幕视频在线免费 | 不卡视频在线 | 天天干天天操 | 欧美日韩在线成人 | 99亚洲精品 | 亚洲欧美精品在线 | 精品视频导航 | 97视频在线观看免费 | 亚洲成人在线网 | 免费观看av网站 | 国产亚洲网站 | 亚洲免费在线观看 | 中文字幕成人免费视频 |