前言介紹
- 這款 WordPress 外掛「WC City Select」是 2015-11-10 上架。
- 目前有 3000 個安裝啟用數。
- 上一次更新是 2025-03-22,距離現在已有 43 天。
- 外掛最低要求 WordPress 4.0 以上版本才可以安裝。
- 有 14 人給過評分。
- 論壇上目前有 1 個提問,問題解答率 0%
外掛協作開發者
外掛標籤
city select | woocommerce | cities select | City Dropdown | cities dropdown |
內容簡介
WooCommerce使用文本輸入是讓客戶輸入城市或鎮的。透過這個外掛,您可以提供一個城市列表來顯示為下拉式選單。
這將顯示在結帳頁面、編輯地址頁面和運費計算機(如果已設定)。
如何添加城市
城市清單必須在functions.php文件中加載(外掛已經包含了一些國家的城市列表)。
使用 wc_city_select_cities 過濾器來加載您的城市。這是類似於添加州/省的方式進行的。
它應該添加在您的functions.php文件或自定義插件中。
add_filter( 'wc_city_select_cities', 'my_cities' );
/**
* 用國家代碼替換XX。代替YYY, ZZZ,使用實際州/省代碼。
*/
function my_cities( $cities ) {
$cities['XX'] = array(
'YYY' => array(
'City ',
'Another City'
),
'ZZZ' => array(
'City 3',
'City 4'
)
);
return $cities;
}
也可以使用一個城市列表,而不把它們按州/省分組:
add_filter( 'wc_city_select_cities', 'my_cities' );
function my_cities( $cities ) {
$cities['XX'] = array(
'City ',
'Another City'
);
return $cities;
}
Github
源代碼和貢獻位於 Github
原文外掛簡介
WooCommerce uses a text input for the customers to enter the city or town. With this plugin you can provide a list of cities to be shown as a select dropdown.
This will be shown in checkout pages, edit addresses pages and shipping calculator if it’s configured that way.
WooCommerce Cart and Checkout Blocks
This plugin is not yet compatible with Blocks.
It works using the legacy shortcodes: [woocommerce_cart] and [woocommerce_checkout].
To make this plugin work, you can use these shortcodes instead of the blocks for your Cart and Checkout pages.
How to add cities
A list of cities has to be loaded in the functions.php file (the plugin already includes cities from some countries).
Use wc_city_select_cities filter to load your cities. This is done similarly to adding states/provinces.
It should be added on your functions.php or a custom plugin.
add_filter( 'wc_city_select_cities', 'my_cities' );
/**
* Replace XX with the country code. Instead of YYY, ZZZ use actual state codes.
*/
function my_cities( $cities ) {
$cities['XX'] = array(
'YYY' => array(
'City ',
'Another City'
),
'ZZZ' => array(
'City 3',
'City 4'
)
);
return $cities;
}
It’s also possible to use a list of cities without grouping them by state:
add_filter( 'wc_city_select_cities', 'my_cities' );
function my_cities( $cities ) {
$cities['XX'] = array(
'City ',
'Another City'
);
return $cities;
}
Github
Source code and contributions at github
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「WC City Select」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.0 | 1.0.1 | 1.0.2 | 1.0.3 | 1.0.4 | 1.0.5 | 1.0.6 | 1.0.7 | 1.0.8 | 1.0.9 | trunk | 1.0.10 |
延伸相關外掛(你可能也想知道)
暫無相關外掛推薦。