15 Commits

Author SHA1 Message Date
Dat Hoang 7f87b70d6c Merge pull request #8 from htdat/1.2-dev
Add the branch 1.2 dev to the master
2017-03-03 18:02:40 +07:00
htdat b61c2499df Prepare for the stable tag 1.2 2017-03-03 18:01:29 +07:00
htdat 5150d9ad17 Fix the wrong text domain 2017-02-26 16:24:05 +07:00
htdat 7083167c33 Add the option "add_city" to the setting page
Issue #4
2017-02-26 16:14:34 +07:00
htdat def805022d Add the new option "add_city" and better manage the options when upgrading 2017-02-26 15:56:45 +07:00
htdat c83e429e41 Add the 'WooViet_Cities' class
Issue #4
2017-02-26 15:26:07 +07:00
htdat 1736fa1207 Add the wc-city-select plugin - version 1.0.3 2017-02-26 14:58:41 +07:00
Dat Hoang 58fee75673 Merge pull request #6 from vietartisans/master
Hehe so cool. It's similar to this #2 
Thank you so much.
2017-01-19 16:31:36 +07:00
Viet Artisans bcb811c7e7 Update table in readme 2017-01-19 16:25:44 +07:00
Viet Artisans c0392e40d3 Readme.md version, it looks better on github 2017-01-19 16:23:18 +07:00
htdat 173367c1ba Delete the POT file
Issue #1 : Remove the POT file. Use this
https://translate.wordpress.org/locale/vi/default/wp-plugins/woo-viet
2017-01-15 15:32:06 +07:00
htdat d66524ae35 Edit a grammar error 2017-01-15 15:02:12 +07:00
htdat aff1b92105 Improve readme.txt - keep English only. 2017-01-06 19:15:55 +07:00
htdat f524fe1385 Use the text domain 'woo-vier' for some strings 2017-01-06 19:08:32 +07:00
htdat 1367213f25 Vietnamese typo in the readme.txt file #3
Add the better name “Woo Viet - WooCommerce for Vietnam”
2017-01-03 12:37:56 +07:00
11 changed files with 2643 additions and 376 deletions
+13 -2
View File
@@ -59,7 +59,7 @@ class WooViet_Admin_Page {
public function register_submenu_page() {
add_submenu_page(
'woocommerce',
'Woo Viet Settings',
__( 'Woo Viet Settings', 'woo-viet' ),
'Woo Viet',
'manage_options',
'woo-viet',
@@ -98,7 +98,18 @@ class WooViet_Admin_Page {
<label for="add_province"><?php _e( 'Enabled', 'woo-viet' ) ?></label>
</td>
</tr>
<tr>
<th scope="row"><?php _e( 'Add districts for Vietnam', 'woo-viet' ) ?><br />
<i><?php _e( 'Require "Add provinces for Vietnam" active', 'woo-viet' ) ?></i>
</th>
<td>
<input name="settings[add_city][enabled]" type="hidden" value="no">
<input name="settings[add_city][enabled]" type="checkbox" id="add_city" value="yes"
<?php if ( 'yes' == $settings['add_city']['enabled'] )
echo 'checked="checked"' ?>>
<label for="add_city"><?php _e( 'Enabled', 'woo-viet' ) ?></label>
</td>
</tr>
<tr>
<th scope="row"><?php _e( 'Change VND currency symbol', 'woo-viet' ) ?></th>
<td>
+887
View File
@@ -0,0 +1,887 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Add Vietnam Cities to WooCommerce
*
* @credit: https://github.com/8manos/wc-city-select
* @author htdat
* @since 1.2
*
*
*/
class WooViet_Cities {
public function __construct() {
/**
* Load the 'WC City Select' class if this plugin is NOT active
*/
if ( ! class_exists( 'WC_City_Select' ) ) {
include( WOO_VIET_DIR . 'lib/wc-city-select/wc-city-select.php' );
}
add_filter( 'wc_city_select_cities', array( $this, 'add_cities' ) );
}
/**
* Add Vietnam Cities
*
* @param $cities
*
* @return array
*/
public function add_cities( $cities ) {
/**
* @source: https://github.com/htdat/woo-viet/issues/4#issuecomment-277449462
* @source: https://gist.github.com/10h30/7e9307d405ff9ef88cf7d226c90a5d13
*/
$cities['VN'] = array(
'AN-GIANG' => array(
'Huyện An Phú',
'Huyện Châu Phú',
'Huyện Châu Thành',
'Huyện Chợ Mới',
'Huyện Phú Tân',
'Huyện Thoại Sơn',
'Huyện Tịnh Biên',
'Huyện Tri Tôn',
'Thành phố Châu Đốc',
'Thành phố Long Xuyên',
'Thị xã Tân Châu'
),
'BA-RIA-VUNG-TAU' => array(
'Huyện Châu Đức',
'Huyện Côn Đảo',
'Huyện Đất Đỏ',
'Huyện Long Điền',
'Huyện Tân Thành',
'Huyện Xuyên Mộc',
'Thành phố Bà Rịa',
'Thành phố Vũng Tàu'
),
'BAC-LIEU' => array(
'Huyện Đông Hải',
'Huyện Hoà Bình',
'Huyện Hồng Dân',
'Huyện Phước Long',
'Huyện Vĩnh Lợi',
'Thành phố Bạc Liêu',
'Thị xã Giá Rai'
),
'BAC-KAN' => array(
'Huyện Ba Bể',
'Huyện Bạch Thông',
'Huyện Chợ Đồn',
'Huyện Chợ Mới',
'Huyện Na Rì',
'Huyện Ngân Sơn',
'Huyện Pác Nặm',
'Thành Phố Bắc Kạn',
),
'BAC-GIANG' => array(
'Huyện Hiệp Hòa',
'Huyện Lạng Giang',
'Huyện Lục Nam',
'Huyện Lục Ngạn',
'Huyện Sơn Động',
'Huyện Tân Yên',
'Huyện Việt Yên',
'Huyện Yên Dũng',
'Huyện Yên Thế',
'Thành phố Bắc Giang'
),
'BAC-NINH' => array(
'Huyện Gia Bình',
'Huyện Lương Tài',
'Huyện Quế Võ',
'Huyện Thuận Thành',
'Huyện Tiên Du',
'Huyện Yên Phong',
'Thành phố Bắc Ninh',
'Thị xã Từ Sơn'
),
'BEN-TRE' => array(
'Huyện Ba Tri',
'Huyện Bình Đại',
'Huyện Châu Thành',
'Huyện Chợ Lách',
'Huyện Giồng Trôm',
'Huyện Mỏ Cày Bắc',
'Huyện Mỏ Cày Nam',
'Huyện Thạnh Phú',
'Thành phố Bến Tre'
),
'BINH-DUONG' => array(
'Huyện Bắc Tân Uyên',
'Huyện Bàu Bàng',
'Huyện Dầu Tiếng',
'Huyện Phú Giáo',
'Thành phố Thủ Dầu Một',
'Thị xã Bến Cát',
'Thị xã Dĩ An',
'Thị xã Tân Uyên',
'Thị xã Thuận An'
),
'BINH-DINH' => array(
'Huyện An Lão',
'Huyện Hoài Ân',
'Huyện Hoài Nhơn',
'Huyện Phù Cát',
'Huyện Phù Mỹ',
'Huyện Tây Sơn',
'Huyện Tuy Phước',
'Huyện Vân Canh',
'Huyện Vĩnh Thạnh',
'Thành phố Qui Nhơn',
'Thị xã An Nhơn'
),
'BINH-PHUOC' => array(
'Huyện Bù Đăng',
'Huyện Bù Đốp',
'Huyện Bù Gia Mập',
'Huyện Chơn Thành',
'Huyện Đồng Phú',
'Huyện Hớn Quản',
'Huyện Lộc Ninh',
'Huyện Phú Riềng',
'Thị xã Bình Long',
'Thị xã Đồng Xoài',
'Thị xã Phước Long'
),
'BINH-THUAN' => array(
'Huyện Bắc Bình',
'Huyện Đức Linh',
'Huyện Hàm Tân',
'Huyện Hàm Thuận Bắc',
'Huyện Hàm Thuận Nam',
'Huyện Phú Quí',
'Huyện Tánh Linh',
'Huyện Tuy Phong',
'Thành phố Phan Thiết',
'Thị xã La Gi'
),
'CA-MAU' => array(
'Huyện Cái Nước',
'Huyện Đầm Dơi',
'Huyện Năm Căn',
'Huyện Ngọc Hiển',
'Huyện Phú Tân',
'Huyện Thới Bình',
'Huyện Trần Văn Thời',
'Huyện U Minh',
'Thành phố Cà Mau'
),
'CAO-BANG' => array(
'Huyện Bảo Lạc',
'Huyện Bảo Lâm',
'Huyện Hạ Lang',
'Huyện Hà Quảng',
'Huyện Hoà An',
'Huyện Nguyên Bình',
'Huyện Phục Hoà',
'Huyện Quảng Uyên',
'Huyện Thạch An',
'Huyện Thông Nông',
'Huyện Trà Lĩnh',
'Huyện Trùng Khánh',
'Thành phố Cao Bằng'
),
'CAN-THO' => array(
'Huyện Cờ Đỏ',
'Huyện Phong Điền',
'Huyện Thới Lai',
'Huyện Vĩnh Thạnh',
'Quận Bình Thuỷ',
'Quận Cái Răng',
'Quận Ninh Kiều',
'Quận Ô Môn',
'Quận Thốt Nốt',
),
'DA-NANG' => array(
'Huyện Hòa Vang',
'Huyện Hoàng Sa',
'Quận Cẩm Lệ',
'Quận Hải Châu',
'Quận Liên Chiểu',
'Quận Ngũ Hành Sơn',
'Quận Sơn Trà',
'Quận Thanh Khê',
),
'DAK-LAK' => array(
'Huyện Buôn Đôn',
'Huyện Cư Kuin',
'Huyện Cư M gar',
'Huyện Ea H leo',
'Huyện Ea Kar',
'Huyện Ea Súp',
'Huyện Krông A Na',
'Huyện Krông Bông',
'Huyện Krông Búk',
'Huyện Krông Năng',
'Huyện Krông Pắc',
'Huyện Lắk',
'Huyện M Đrắk',
'Thành phố Buôn Ma Thuột',
'Thị Xã Buôn Hồ'
),
'DAK-NONG' => array(
'Huyện Cư Jút',
'Huyện Đăk Glong',
'Huyện Đắk Mil',
'Huyện Đắk R Lấp',
'Huyện Đắk Song',
'Huyện Krông Nô',
'Huyện Tuy Đức',
'Thị xã Gia Nghĩa'
),
'DONG-NAI' => array(
'Huyện Cẩm Mỹ',
'Huyện Định Quán',
'Huyện Long Thành',
'Huyện Nhơn Trạch',
'Huyện Tân Phú',
'Huyện Thống Nhất',
'Huyện Trảng Bom',
'Huyện Vĩnh Cửu',
'Huyện Xuân Lộc',
'Thành phố Biên Hòa',
'Thị xã Long Khánh'
),
'DONG-THAP' => array(
'Huyện Cao Lãnh',
'Huyện Châu Thành',
'Huyện Hồng Ngự',
'Huyện Lai Vung',
'Huyện Lấp Vò',
'Huyện Tam Nông',
'Huyện Tân Hồng',
'Huyện Thanh Bình',
'Huyện Tháp Mười',
'Thành phố Cao Lãnh',
'Thành phố Sa Đéc',
'Thị xã Hồng Ngự'
),
'DIEN-BIEN' => array(
'Huyện Điện Biên',
'Huyện Điện Biên Đông',
'Huyện Mường Ảng',
'Huyện Mường Chà',
'Huyện Mường Nhé',
'Huyện Nậm Pồ',
'Huyện Tủa Chùa',
'Huyện Tuần Giáo',
'Thành phố Điện Biên Phủ',
'Thị Xã Mường Lay'
),
'GIA-LAI' => array(
'Huyện Chư Păh',
'Huyện Chư Prông',
'Huyện Chư Pưh',
'Huyện Chư Sê',
'Huyện Đăk Đoa',
'Huyện Đăk Pơ',
'Huyện Đức Cơ',
'Huyện Ia Grai',
'Huyện Ia Pa',
'Huyện KBang',
'Huyện Kông Chro',
'Huyện Krông Pa',
'Huyện Mang Yang',
'Huyện Phú Thiện',
'Thành phố Pleiku',
'Thị xã An Khê',
'Thị xã Ayun Pa'
),
'HA-GIANG' => array(
'Huyện Bắc Mê',
'Huyện Bắc Quang',
'Huyện Đồng Văn',
'Huyện Hoàng Su Phì',
'Huyện Mèo Vạc',
'Huyện Quản Bạ',
'Huyện Quang Bình',
'Huyện Vị Xuyên',
'Huyện Xín Mần',
'Huyện Yên Minh',
'Thành phố Hà Giang'
),
'HA-NAM' => array(
'Huyện Bình Lục',
'Huyện Duy Tiên',
'Huyện Kim Bảng',
'Huyện Lý Nhân',
'Huyện Thanh Liêm',
'Thành phố Phủ Lý'
),
'HA-NOI' => array(
'Huyện Ba Vì',
'Huyện Chương Mỹ',
'Huyện Đan Phượng',
'Huyện Đông Anh',
'Huyện Gia Lâm',
'Huyện Hoài Đức',
'Huyện Mê Linh',
'Huyện Mỹ Đức',
'Huyện Phú Xuyên',
'Huyện Phúc Thọ',
'Huyện Quốc Oai',
'Huyện Sóc Sơn',
'Huyện Thạch Thất',
'Huyện Thanh Oai',
'Huyện Thanh Trì',
'Huyện Thường Tín',
'Huyện Ứng Hòa',
'Quận Ba Đình',
'Quận Bắc Từ Liêm',
'Quận Cầu Giấy',
'Quận Đống Đa',
'Quận Hà Đông',
'Quận Hai Bà Trưng',
'Quận Hoàn Kiếm',
'Quận Hoàng Mai',
'Quận Long Biên',
'Quận Nam Từ Liêm',
'Quận Tây Hồ',
'Quận Thanh Xuân',
'Thị xã Sơn Tây'
),
'HA-TINH' => array(
'Huyện Cẩm Xuyên',
'Huyện Can Lộc',
'Huyện Đức Thọ',
'Huyện Hương Khê',
'Huyện Hương Sơn',
'Huyện Kỳ Anh',
'Huyện Lộc Hà',
'Huyện Nghi Xuân',
'Huyện Thạch Hà',
'Huyện Vũ Quang',
'Thành phố Hà Tĩnh',
'Thị xã Hồng Lĩnh',
'Thị xã Kỳ Anh'
),
'HAI-DUONG' => array(
'Huyện Bình Giang',
'Huyện Cẩm Giàng',
'Huyện Gia Lộc',
'Huyện Kim Thành',
'Huyện Kinh Môn',
'Huyện Nam Sách',
'Huyện Ninh Giang',
'Huyện Thanh Hà',
'Huyện Thanh Miện',
'Huyện Tứ Kỳ',
'Thành phố Hải Dương',
'Thị xã Chí Linh'
),
'HAI-PHONG' => array(
'Huyện An Dương',
'Huyện An Lão',
'Huyện Bạch Long Vĩ',
'Huyện Cát Hải',
'Huyện Kiến Thuỵ',
'Huyện Thuỷ Nguyên',
'Huyện Tiên Lãng',
'Huyện Vĩnh Bảo',
'Quận Đồ Sơn',
'Quận Dương Kinh',
'Quận Hải An',
'Quận Hồng Bàng',
'Quận Kiến An',
'Quận Lê Chân',
'Quận Ngô Quyền'
),
'HOA-BINH' => array(
'Huyện Cao Phong',
'Huyện Đà Bắc',
'Huyện Kim Bôi',
'Huyện Kỳ Sơn',
'Huyện Lạc Sơn',
'Huyện Lạc Thủy',
'Huyện Lương Sơn',
'Huyện Mai Châu',
'Huyện Tân Lạc',
'Huyện Yên Thủy',
'Thành phố Hòa Bình'
),
'HAU-GIANG' => array(
'Huyện Châu Thành',
'Huyện Châu Thành A',
'Huyện Long Mỹ',
'Huyện Phụng Hiệp',
'Huyện Vị Thuỷ',
'Thành phố Vị Thanh',
'Thị xã Long Mỹ',
'Thị xã Ngã Bảy'
),
'HUNG-YEN' => array(
'Huyện Ân Thi',
'Huyện Khoái Châu',
'Huyện Kim Động',
'Huyện Mỹ Hào',
'Huyện Phù Cừ',
'Huyện Tiên Lữ',
'Huyện Văn Giang',
'Huyện Văn Lâm',
'Huyện Yên Mỹ',
'Thành phố Hưng Yên'
),
'HO-CHI-MINH' => array(
'Huyện Bình Chánh',
'Huyện Cần Giờ',
'Huyện Củ Chi',
'Huyện Hóc Môn',
'Huyện Nhà Bè',
'Quận 1',
'Quận 10',
'Quận 11',
'Quận 12',
'Quận 2',
'Quận 3',
'Quận 4',
'Quận 5',
'Quận 6',
'Quận 7',
'Quận 8',
'Quận 9',
'Quận Bình Tân',
'Quận Bình Thạnh',
'Quận Gò Vấp',
'Quận Phú Nhuận',
'Quận Tân Bình',
'Quận Tân Phú',
'Quận Thủ Đức'
),
'KHANH-HOA' => array(
'Huyện Cam Lâm',
'Huyện Diên Khánh',
'Huyện Khánh Sơn',
'Huyện Khánh Vĩnh',
'Huyện Trường Sa',
'Huyện Vạn Ninh',
'Thành phố Cam Ranh',
'Thành phố Nha Trang',
'Thị xã Ninh Hòa'
),
'KIEN-GIANG' => array(
'Huyện An Biên',
'Huyện An Minh',
'Huyện Châu Thành',
'Huyện Giang Thành',
'Huyện Giồng Riềng',
'Huyện Gò Quao',
'Huyện Hòn Đất',
'Huyện Kiên Hải',
'Huyện Kiên Lương',
'Huyện Phú Quốc',
'Huyện Tân Hiệp',
'Huyện U Minh Thượng',
'Huyện Vĩnh Thuận',
'Thành phố Rạch Giá',
'Thị xã Hà Tiên'
),
'KON-TUM' => array(
'Huyện Đắk Glei',
'Huyện Đắk Hà',
'Huyện Đắk Tô',
'Huyện Ia H Drai',
'Huyện Kon Plông',
'Huyện Kon Rẫy',
'Huyện Ngọc Hồi',
'Huyện Sa Thầy',
'Huyện Tu Mơ Rông',
'Thành phố Kon Tum'
),
'LAI-CHAU' => array(
'Huyện Mường Tè',
'Huyện Nậm Nhùn',
'Huyện Phong Thổ',
'Huyện Sìn Hồ',
'Huyện Tam Đường',
'Huyện Tân Uyên',
'Huyện Than Uyên',
'Thành phố Lai Châu'
),
'LAO-CAI' => array(
'Huyện Bắc Hà',
'Huyện Bảo Thắng',
'Huyện Bảo Yên',
'Huyện Bát Xát',
'Huyện Mường Khương',
'Huyện Sa Pa',
'Huyện Si Ma Cai',
'Huyện Văn Bàn',
'Thành phố Lào Cai'
),
'LANG-SON' => array(
'Huyện Bắc Sơn',
'Huyện Bình Gia',
'Huyện Cao Lộc',
'Huyện Chi Lăng',
'Huyện Đình Lập',
'Huyện Hữu Lũng',
'Huyện Lộc Bình',
'Huyện Tràng Định',
'Huyện Văn Lãng',
'Huyện Văn Quan',
'Thành phố Lạng Sơn'
),
'LAM-DONG' => array(
'Huyện Bảo Lâm',
'Huyện Cát Tiên',
'Huyện Đạ Huoai',
'Huyện Đạ Tẻh',
'Huyện Đam Rông',
'Huyện Di Linh',
'Huyện Đơn Dương',
'Huyện Đức Trọng',
'Huyện Lạc Dương',
'Huyện Lâm Hà',
'Thành phố Bảo Lộc',
'Thành phố Đà Lạt'
),
'LONG-AN' => array(
'Huyện Bến Lức',
'Huyện Cần Đước',
'Huyện Cần Giuộc',
'Huyện Châu Thành',
'Huyện Đức Hòa',
'Huyện Đức Huệ',
'Huyện Mộc Hóa',
'Huyện Tân Hưng',
'Huyện Tân Thạnh',
'Huyện Tân Trụ',
'Huyện Thạnh Hóa',
'Huyện Thủ Thừa',
'Huyện Vĩnh Hưng',
'Thành phố Tân An',
'Thị xã Kiến Tường'
),
'NAM-DINH' => array(
'Huyện Giao Thủy',
'Huyện Hải Hậu',
'Huyện Mỹ Lộc',
'Huyện Nam Trực',
'Huyện Nghĩa Hưng',
'Huyện Trực Ninh',
'Huyện Vụ Bản',
'Huyện Xuân Trường',
'Huyện Ý Yên',
'Thành phố Nam Định'
),
'NGHE-AN' => array(
'Huyện Anh Sơn',
'Huyện Con Cuông',
'Huyện Diễn Châu',
'Huyện Đô Lương',
'Huyện Hưng Nguyên',
'Huyện Kỳ Sơn',
'Huyện Nam Đàn',
'Huyện Nghi Lộc',
'Huyện Nghĩa Đàn',
'Huyện Quế Phong',
'Huyện Quỳ Châu',
'Huyện Quỳ Hợp',
'Huyện Quỳnh Lưu',
'Huyện Tân Kỳ',
'Huyện Thanh Chương',
'Huyện Tương Dương',
'Huyện Yên Thành',
'Thành phố Vinh',
'Thị xã Cửa Lò',
'Thị xã Hoàng Mai',
'Thị xã Thái Hoà'
),
'NINH-BINH' => array(
'Huyện Gia Viễn',
'Huyện Hoa Lư',
'Huyện Kim Sơn',
'Huyện Nho Quan',
'Huyện Yên Khánh',
'Huyện Yên Mô',
'Thành phố Ninh Bình',
'Thành phố Tam Điệp'
),
'NINH-THUAN' => array(
'Huyện Bác Ái',
'Huyện Ninh Hải',
'Huyện Ninh Phước',
'Huyện Ninh Sơn',
'Huyện Thuận Bắc',
'Huyện Thuận Nam',
'Thành phố Phan Rang-Tháp Chàm'
),
'PHU-THO' => array(
'Huyện Cẩm Khê',
'Huyện Đoan Hùng',
'Huyện Hạ Hoà',
'Huyện Lâm Thao',
'Huyện Phù Ninh',
'Huyện Tam Nông',
'Huyện Tân Sơn',
'Huyện Thanh Ba',
'Huyện Thanh Sơn',
'Huyện Thanh Thuỷ',
'Huyện Yên Lập',
'Thành phố Việt Trì',
'Thị xã Phú Thọ'
),
'PHU-YEN' => array(
'Huyện Đông Hòa',
'Huyện Đồng Xuân',
'Huyện Phú Hoà',
'Huyện Sơn Hòa',
'Huyện Sông Hinh',
'Huyện Tây Hoà',
'Huyện Tuy An',
'Thành phố Tuy Hoà',
'Thị xã Sông Cầu'
),
'QUANG-BINH' => array(
'Huyện Bố Trạch',
'Huyện Lệ Thủy',
'Huyện Minh Hóa',
'Huyện Quảng Ninh',
'Huyện Quảng Trạch',
'Huyện Tuyên Hóa',
'Thành Phố Đồng Hới',
'Thị xã Ba Đồn'
),
'QUANG-NAM' => array(
'Huyện Bắc Trà My',
'Huyện Đại Lộc',
'Huyện Đông Giang',
'Huyện Duy Xuyên',
'Huyện Hiệp Đức',
'Huyện Nam Giang',
'Huyện Nam Trà My',
'Huyện Nông Sơn',
'Huyện Núi Thành',
'Huyện Phú Ninh',
'Huyện Phước Sơn',
'Huyện Quế Sơn',
'Huyện Tây Giang',
'Huyện Thăng Bình',
'Huyện Tiên Phước',
'Thành phố Hội An',
'Thành phố Tam Kỳ',
'Thị xã Điện Bàn'
),
'QUANG-NGAI' => array(
'Huyện Ba Tơ',
'Huyện Bình Sơn',
'Huyện Đức Phổ',
'Huyện Lý Sơn',
'Huyện Minh Long',
'Huyện Mộ Đức',
'Huyện Nghĩa Hành',
'Huyện Sơn Hà',
'Huyện Sơn Tây',
'Huyện Sơn Tịnh',
'Huyện Tây Trà',
'Huyện Trà Bồng',
'Huyện Tư Nghĩa',
'Thành phố Quảng Ngãi'
),
'QUANG-NINH' => array(
'Huyện Ba Chẽ',
'Huyện Bình Liêu',
'Huyện Cô Tô',
'Huyện Đầm Hà',
'Huyện Hải Hà',
'Huyện Hoành Bồ',
'Huyện Tiên Yên',
'Huyện Vân Đồn',
'Thành phố Cẩm Phả',
'Thành phố Hạ Long',
'Thành phố Móng Cái',
'Thành phố Uông Bí',
'Thị xã Đông Triều',
'Thị xã Quảng Yên'
),
'QUANG-TRI' => array(
'Huyện Cam Lộ',
'Huyện Cồn Cỏ',
'Huyện Đa Krông',
'Huyện Gio Linh',
'Huyện Hải Lăng',
'Huyện Hướng Hóa',
'Huyện Triệu Phong',
'Huyện Vĩnh Linh',
'Thành phố Đông Hà',
'Thị xã Quảng Trị'
),
'SOC-TRANG' => array(
'Huyện Châu Thành',
'Huyện Cù Lao Dung',
'Huyện Kế Sách',
'Huyện Long Phú',
'Huyện Mỹ Tú',
'Huyện Mỹ Xuyên',
'Huyện Thạnh Trị',
'Huyện Trần Đề',
'Thành phố Sóc Trăng',
'Thị xã Ngã Năm',
'Thị xã Vĩnh Châu'
),
'SON-LA' => array(
'Huyện Bắc Yên',
'Huyện Mai Sơn',
'Huyện Mộc Châu',
'Huyện Mường La',
'Huyện Phù Yên',
'Huyện Quỳnh Nhai',
'Huyện Sông Mã',
'Huyện Sốp Cộp',
'Huyện Thuận Châu',
'Huyện Vân Hồ',
'Huyện Yên Châu',
'Thành phố Sơn La'
),
'TAY-NINH' => array(
'Huyện Bến Cầu',
'Huyện Châu Thành',
'Huyện Dương Minh Châu',
'Huyện Gò Dầu',
'Huyện Hòa Thành',
'Huyện Tân Biên',
'Huyện Tân Châu',
'Huyện Trảng Bàng',
'Thành phố Tây Ninh'
),
'THAI-BINH' => array(
'Huyện Đông Hưng',
'Huyện Hưng Hà',
'Huyện Kiến Xương',
'Huyện Quỳnh Phụ',
'Huyện Thái Thụy',
'Huyện Tiền Hải',
'Huyện Vũ Thư',
'Thành phố Thái Bình'
),
'THAI-NGUYEN' => array(
'Huyện Đại Từ',
'Huyện Định Hóa',
'Huyện Đồng Hỷ',
'Huyện Phú Bình',
'Huyện Phú Lương',
'Huyện Võ Nhai',
'Thành phố Sông Công',
'Thành phố Thái Nguyên',
'Thị xã Phổ Yên'
),
'THANH-HOA' => array(
'Huyện Bá Thước',
'Huyện Cẩm Thủy',
'Huyện Đông Sơn',
'Huyện Hà Trung',
'Huyện Hậu Lộc',
'Huyện Hoằng Hóa',
'Huyện Lang Chánh',
'Huyện Mường Lát',
'Huyện Nga Sơn',
'Huyện Ngọc Lặc',
'Huyện Như Thanh',
'Huyện Như Xuân',
'Huyện Nông Cống',
'Huyện Quan Hóa',
'Huyện Quan Sơn',
'Huyện Quảng Xương',
'Huyện Thạch Thành',
'Huyện Thiệu Hóa',
'Huyện Thọ Xuân',
'Huyện Thường Xuân',
'Huyện Tĩnh Gia',
'Huyện Triệu Sơn',
'Huyện Vĩnh Lộc',
'Huyện Yên Định',
'Thành phố Thanh Hóa',
'Thị xã Bỉm Sơn',
'Thị xã Sầm Sơn'
),
'THUA-THIEN-HUE' => array(
'Huyện A Lưới',
'Huyện Nam Đông',
'Huyện Phong Điền',
'Huyện Phú Lộc',
'Huyện Phú Vang',
'Huyện Quảng Điền',
'Thành phố Huế',
'Thị xã Hương Thủy',
'Thị xã Hương Trà'
),
'TIEN-GIANG' => array(
'Huyện Cái Bè',
'Huyện Cai Lậy',
'Huyện Châu Thành',
'Huyện Chợ Gạo',
'Huyện Gò Công Đông',
'Huyện Gò Công Tây',
'Huyện Tân Phú Đông',
'Huyện Tân Phước',
'Thành phố Mỹ Tho',
'Thị xã Cai Lậy',
'Thị xã Gò Công'
),
'TRA-VINH' => array(
'Huyện Càng Long',
'Huyện Cầu Kè',
'Huyện Cầu Ngang',
'Huyện Châu Thành',
'Huyện Duyên Hải',
'Huyện Tiểu Cần',
'Huyện Trà Cú',
'Thành phố Trà Vinh',
'Thị xã Duyên Hải'
),
'TUYEN-QUANG' => array(
'Huyện Chiêm Hóa',
'Huyện Hàm Yên',
'Huyện Lâm Bình',
'Huyện Nà Hang',
'Huyện Sơn Dương',
'Huyện Yên Sơn',
'Thành phố Tuyên Quang'
),
'VINH-LONG' => array(
'Huyện Vũng Liêm',
'Huyện Bình Tân',
'Huyện Long Hồ',
'Huyện Mang Thít',
'Huyện Tam Bình',
'Huyện Trà Ôn',
'Thành phố Vĩnh Long',
'Thị xã Bình Minh'
),
'VINH-PHUC' => array(
'Huyện Bình Xuyên',
'Huyện Lập Thạch',
'Huyện Sông Lô',
'Huyện Tam Đảo',
'Huyện Tam Dương',
'Huyện Vĩnh Tường',
'Huyện Yên Lạc',
'Thành phố Vĩnh Yên',
'Thị xã Phúc Yên'
),
'YEN-BAI' => array(
'Huyện Lục Yên',
'Huyện Mù Căng Chải',
'Huyện Trạm Tấu',
'Huyện Trấn Yên',
'Huyện Văn Chấn',
'Huyện Văn Yên',
'Huyện Yên Bình',
'Thành phố Yên Bái',
'Thị xã Nghĩa Lộ'
),
);
return $cities;
}
}
+2 -2
View File
@@ -46,10 +46,10 @@ class WooViet_Provinces {
* @return array
*/
public function edit_vn_locale( $array ) {
$array['VN']['state']['label'] = __( 'Province', 'woocommerce' );
$array['VN']['state']['label'] = __( 'Province', 'woo-viet' );
$array['VN']['state']['required'] = true;
$array['VN']['city']['label'] = __( 'District', 'woocommerce' );
$array['VN']['city']['label'] = __( 'District', 'woo-viet' );
$array['VN']['postcode']['hidden'] = true;
return $array;
-349
View File
@@ -1,349 +0,0 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-01 12:58+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: \n"
"Language: \n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco https://localise.biz/"
#: woo-viet.php:87
msgid ""
"Woo Viet is not running because WooCommerce is not active. "
"Please activate both plugins"
msgstr ""
#: inc/class-wooviet-admin-page.php:43
msgid "Settings saved"
msgstr ""
#: inc/class-wooviet-admin-page.php:50
msgid "Can not save settings! Please refresh this page."
msgstr ""
#: inc/class-wooviet-admin-page.php:92
msgid "Add provinces for Vietnam"
msgstr ""
#: inc/class-wooviet-admin-page.php:98 inc/class-wooviet-admin-page.php:110
#: inc/class-wooviet-admin-page.php:127 inc/class-wooviet-admin-page.php:146
msgid "Enabled"
msgstr ""
#: inc/class-wooviet-admin-page.php:103
msgid "Change VND currency symbol"
msgstr ""
#: inc/class-wooviet-admin-page.php:116
msgid "Insert a text to change the default symbol <code>đ</code>"
msgstr ""
#: inc/class-wooviet-admin-page.php:120
msgid "Convert <code>000</code> of prices to K (or anything)"
msgstr ""
#: inc/class-wooviet-admin-page.php:133
msgid "Choose what you want to change. E.g:"
msgstr ""
#: inc/class-wooviet-admin-page.php:139
#, php-format
msgid "Support VND for <a href=\"%s\">the PayPal Standard gateway</a>"
msgstr ""
#: inc/class-wooviet-admin-page.php:191
msgid ""
"Select a PayPal supported currency (like USD, EUR, etc), which is used to "
"convert VND prices"
msgstr ""
#: inc/class-wooviet-admin-page.php:198
msgid "Insert the exchange rate of this currency to VND"
msgstr ""
#: inc/class-wooviet-provinces.php:71
msgid "An Giang"
msgstr ""
#: inc/class-wooviet-provinces.php:72
msgid "Ba Ria - Vung Tau"
msgstr ""
#: inc/class-wooviet-provinces.php:73
msgid "Bac Lieu"
msgstr ""
#: inc/class-wooviet-provinces.php:74
msgid "Bac Kan"
msgstr ""
#: inc/class-wooviet-provinces.php:75
msgid "Bac Giang"
msgstr ""
#: inc/class-wooviet-provinces.php:76
msgid "Bac Ninh"
msgstr ""
#: inc/class-wooviet-provinces.php:77
msgid "Ben Tre"
msgstr ""
#: inc/class-wooviet-provinces.php:78
msgid "Binh Duong"
msgstr ""
#: inc/class-wooviet-provinces.php:79
msgid "Binh Dinh"
msgstr ""
#: inc/class-wooviet-provinces.php:80
msgid "Binh Phuoc"
msgstr ""
#: inc/class-wooviet-provinces.php:81
msgid "Binh Thuan"
msgstr ""
#: inc/class-wooviet-provinces.php:82
msgid "Ca Mau"
msgstr ""
#: inc/class-wooviet-provinces.php:83
msgid "Cao Bang"
msgstr ""
#: inc/class-wooviet-provinces.php:84
msgid "Can Tho"
msgstr ""
#: inc/class-wooviet-provinces.php:85
msgid "Da Nang"
msgstr ""
#: inc/class-wooviet-provinces.php:86
msgid "Dak Lak"
msgstr ""
#: inc/class-wooviet-provinces.php:87
msgid "Dak Nong"
msgstr ""
#: inc/class-wooviet-provinces.php:88
msgid "Dong Nai"
msgstr ""
#: inc/class-wooviet-provinces.php:89
msgid "Dong Thap"
msgstr ""
#: inc/class-wooviet-provinces.php:90
msgid "Dien Bien"
msgstr ""
#: inc/class-wooviet-provinces.php:91
msgid "Gia Lai"
msgstr ""
#: inc/class-wooviet-provinces.php:92
msgid "Ha Giang"
msgstr ""
#: inc/class-wooviet-provinces.php:93
msgid "Ha Nam"
msgstr ""
#: inc/class-wooviet-provinces.php:94
msgid "Ha Noi"
msgstr ""
#: inc/class-wooviet-provinces.php:95
msgid "Ha Tinh"
msgstr ""
#: inc/class-wooviet-provinces.php:96
msgid "Hai Duong"
msgstr ""
#: inc/class-wooviet-provinces.php:97
msgid "Hai Phong"
msgstr ""
#: inc/class-wooviet-provinces.php:98
msgid "Hoa Binh"
msgstr ""
#: inc/class-wooviet-provinces.php:99
msgid "Hau Giang"
msgstr ""
#: inc/class-wooviet-provinces.php:100
msgid "Hung Yen"
msgstr ""
#: inc/class-wooviet-provinces.php:101
msgid "Ho Chi Minh"
msgstr ""
#: inc/class-wooviet-provinces.php:102
msgid "Khanh Hoa"
msgstr ""
#: inc/class-wooviet-provinces.php:103
msgid "Kien Giang"
msgstr ""
#: inc/class-wooviet-provinces.php:104
msgid "Kon Tum"
msgstr ""
#: inc/class-wooviet-provinces.php:105
msgid "Lai Chau"
msgstr ""
#: inc/class-wooviet-provinces.php:106
msgid "Lao Cai"
msgstr ""
#: inc/class-wooviet-provinces.php:107
msgid "Lang Son"
msgstr ""
#: inc/class-wooviet-provinces.php:108
msgid "Lam Dong"
msgstr ""
#: inc/class-wooviet-provinces.php:109
msgid "Long An"
msgstr ""
#: inc/class-wooviet-provinces.php:110
msgid "Nam Dinh"
msgstr ""
#: inc/class-wooviet-provinces.php:111
msgid "Nghe An"
msgstr ""
#: inc/class-wooviet-provinces.php:112
msgid "Ninh Binh"
msgstr ""
#: inc/class-wooviet-provinces.php:113
msgid "Ninh Thuan"
msgstr ""
#: inc/class-wooviet-provinces.php:114
msgid "Phu Tho"
msgstr ""
#: inc/class-wooviet-provinces.php:115
msgid "Phu Yen"
msgstr ""
#: inc/class-wooviet-provinces.php:116
msgid "Quang Binh"
msgstr ""
#: inc/class-wooviet-provinces.php:117
msgid "Quang Nam"
msgstr ""
#: inc/class-wooviet-provinces.php:118
msgid "Quang Ngai"
msgstr ""
#: inc/class-wooviet-provinces.php:119
msgid "Quang Ninh"
msgstr ""
#: inc/class-wooviet-provinces.php:120
msgid "Quang Tri"
msgstr ""
#: inc/class-wooviet-provinces.php:121
msgid "Soc Trang"
msgstr ""
#: inc/class-wooviet-provinces.php:122
msgid "Son La"
msgstr ""
#: inc/class-wooviet-provinces.php:123
msgid "Tay Ninh"
msgstr ""
#: inc/class-wooviet-provinces.php:124
msgid "Thai Binh"
msgstr ""
#: inc/class-wooviet-provinces.php:125
msgid "Thai Nguyen"
msgstr ""
#: inc/class-wooviet-provinces.php:126
msgid "Thanh Hoa"
msgstr ""
#: inc/class-wooviet-provinces.php:127
msgid "Thua Thien - Hue"
msgstr ""
#: inc/class-wooviet-provinces.php:128
msgid "Tien Giang"
msgstr ""
#: inc/class-wooviet-provinces.php:129
msgid "Tra Vinh"
msgstr ""
#: inc/class-wooviet-provinces.php:130
msgid "Tuyen Quang"
msgstr ""
#: inc/class-wooviet-provinces.php:131
msgid "Vinh Long"
msgstr ""
#: inc/class-wooviet-provinces.php:132
msgid "Vinh Phuc"
msgstr ""
#: inc/class-wooviet-provinces.php:133
msgid "Yen Bai"
msgstr ""
#: inc/class-wooviet-vnd-paypal-standard.php:100
#, php-format
msgid ""
"The prices will be converted to %1$s in the PayPal pages with the exchange "
"rate %2$s."
msgstr ""
#. Name of the plugin
msgid "Woo Viet"
msgstr ""
#. Description of the plugin
msgid ""
"This plugin provides features and integrations specifically for Vietnam."
msgstr ""
#. URI of the plugin
msgid "https://github.com/htdat/woo-viet"
msgstr ""
#. Author of the plugin
msgid "htdat"
msgstr ""
#. Author URI of the plugin
msgid "https://profiles.wordpress.org/htdat"
msgstr ""
+180
View File
@@ -0,0 +1,180 @@
jQuery( function($) {
// wc_city_select_params is required to continue, ensure the object exists
// wc_country_select_params is used for select2 texts. This one is added by WC
if ( typeof wc_country_select_params === 'undefined' || typeof wc_city_select_params === 'undefined' ) {
return false;
}
function getEnhancedSelectFormatString() {
var formatString = {
formatMatches: function( matches ) {
if ( 1 === matches ) {
return wc_country_select_params.i18n_matches_1;
}
return wc_country_select_params.i18n_matches_n.replace( '%qty%', matches );
},
formatNoMatches: function() {
return wc_country_select_params.i18n_no_matches;
},
formatAjaxError: function() {
return wc_country_select_params.i18n_ajax_error;
},
formatInputTooShort: function( input, min ) {
var number = min - input.length;
if ( 1 === number ) {
return wc_country_select_params.i18n_input_too_short_1;
}
return wc_country_select_params.i18n_input_too_short_n.replace( '%qty%', number );
},
formatInputTooLong: function( input, max ) {
var number = input.length - max;
if ( 1 === number ) {
return wc_country_select_params.i18n_input_too_long_1;
}
return wc_country_select_params.i18n_input_too_long_n.replace( '%qty%', number );
},
formatSelectionTooBig: function( limit ) {
if ( 1 === limit ) {
return wc_country_select_params.i18n_selection_too_long_1;
}
return wc_country_select_params.i18n_selection_too_long_n.replace( '%qty%', limit );
},
formatLoadMore: function() {
return wc_country_select_params.i18n_load_more;
},
formatSearching: function() {
return wc_country_select_params.i18n_searching;
}
};
return formatString;
}
// Select2 Enhancement if it exists
if ( $().select2 ) {
var wc_city_select_select2 = function() {
$( 'select.city_select:visible' ).each( function() {
var select2_args = $.extend({
placeholderOption: 'first',
width: '100%'
}, getEnhancedSelectFormatString() );
$( this ).select2( select2_args );
});
};
wc_city_select_select2();
$( document.body ).bind( 'city_to_select', function() {
wc_city_select_select2();
});
}
/* City select boxes */
var cities_json = wc_city_select_params.cities.replace( /&quot;/g, '"' );
var cities = $.parseJSON( cities_json );
$( 'body' ).on( 'country_to_state_changing', function(e, country, $container) {
var $statebox = $container.find( '#billing_state, #shipping_state, #calc_shipping_state' );
var state = $statebox.val();
$( document.body ).trigger( 'state_changing', [country, state, $container ] );
});
$( 'body' ).on( 'change', 'select.state_select, #calc_shipping_state', function() {
var $container = $( this ).closest( 'div' );
var country = $container.find( '#billing_country, #shipping_country, #calc_shipping_country' ).val();
var state = $( this ).val();
$( document.body ).trigger( 'state_changing', [country, state, $container ] );
});
$( 'body' ).on( 'state_changing', function(e, country, state, $container) {
var $citybox = $container.find( '#billing_city, #shipping_city, #calc_shipping_city' );
if ( cities[ country ] ) {
/* if the country has no states */
if( cities[country] instanceof Array) {
cityToSelect( $citybox, cities[ country ] );
} else if ( state ) {
if ( cities[ country ][ state ] ) {
cityToSelect( $citybox, cities[ country ][ state ] );
} else {
cityToInput( $citybox );
}
} else {
disableCity( $citybox );
}
} else {
cityToInput( $citybox );
}
});
/* Ajax replaces .cart_totals (child of .cart-collaterals) on shipping calculator */
if ( $( '.cart-collaterals' ).length && $( '#calc_shipping_state' ).length ) {
var calc_observer = new MutationObserver( function() {
$( '#calc_shipping_state' ).change();
});
calc_observer.observe( document.querySelector( '.cart-collaterals' ), { childList: true });
}
function cityToInput( $citybox ) {
if ( $citybox.is('input') ) {
$citybox.prop( 'disabled', false );
return;
}
var input_name = $citybox.attr( 'name' );
var input_id = $citybox.attr( 'id' );
var placeholder = $citybox.attr( 'placeholder' );
$citybox.parent().find( '.select2-container' ).remove();
$citybox.replaceWith( '<input type="text" class="input-text" name="' + input_name + '" id="' + input_id + '" placeholder="' + placeholder + '" />' );
}
function disableCity( $citybox ) {
$citybox.val( '' ).change();
$citybox.prop( 'disabled', true );
}
function cityToSelect( $citybox, current_cities ) {
var value = $citybox.val();
if ( $citybox.is('input') ) {
var input_name = $citybox.attr( 'name' );
var input_id = $citybox.attr( 'id' );
var placeholder = $citybox.attr( 'placeholder' );
$citybox.replaceWith( '<select name="' + input_name + '" id="' + input_id + '" class="city_select" placeholder="' + placeholder + '"></select>' );
//we have to assign the new object, because of replaceWith
$citybox = $('#'+input_id);
} else {
$citybox.prop( 'disabled', false );
}
var options = '';
for( var index in current_cities ) {
if ( current_cities.hasOwnProperty( index ) ) {
var cityName = current_cities[ index ];
options = options + '<option value="' + cityName + '">' + cityName + '</option>';
}
}
$citybox.html( '<option value="">' + wc_city_select_params.i18n_select_city_text + '</option>' + options );
if ( $('option[value="'+value+'"]', $citybox).length ) {
$citybox.val( value ).change();
} else {
$citybox.val( '' ).change();
}
$( document.body ).trigger( 'city_to_select' );
}
});
File diff suppressed because it is too large Load Diff
+79
View File
@@ -0,0 +1,79 @@
=== WC City Select ===
Contributors: mantish
Donate link: mailto:paypal@8manos.com
Tags: woocommerce, cities, city, city select, cities select, city dropdown, cities dropdown, woocommerce city, woocommerce cities
Requires at least: 4.0
Tested up to: 4.7.3
Stable tag: 1.0.3
WC requires at least: 2.2
WC tested up to: 2.7.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
City Select for WooCommerce. Show a dropdown select as the cities input.
== Description ==
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.
A list of cities has to be loaded in the functions.php file (the plugin already includes cities from Colombia and Iran). Please check the Installation section for more info.
### Github
Contribute at https://github.com/8manos/wc-city-select
== Installation ==
1. Upload to the `/wp-content/plugins/` directory
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Use `wc_city_select_cities` filter to load your cities. This is done similarly to [adding states/provinces](https://docs.woothemes.com/document/addmodify-states/). 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;
}
`
== Changelog ==
= 1.0.3 =
* fix some issues when loading cities initially, that were causing warnings.
= 1.0.2 =
* fix some issues with shipping calculator and other edge cases.
* Now works with countries that have no states, only cities.
= 1.0.1 =
* select2 enhancement when available. Adds a JS version of the select dropdown.
= 1.0 =
* First release.
+196
View File
@@ -0,0 +1,196 @@
<?php
/**
* Plugin Name: WC City Select
* Plugin URI: https://wordpress.org/plugins/wc-city-select/
* Description: City Select for WooCommerce. Show a dropdown select as the cities input.
* Version: 1.0.3
* Author: 8manos
* Author URI: http://8manos.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Check if WooCommerce is active
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
class WC_City_Select {
// plugin version
const VERSION = '1.0.1';
private $plugin_path;
private $plugin_url;
private $cities;
public function __construct() {
add_filter( 'woocommerce_billing_fields', array( $this, 'billing_fields' ), 10, 2 );
add_filter( 'woocommerce_shipping_fields', array( $this, 'shipping_fields' ), 10, 2 );
add_filter( 'woocommerce_form_field_city', array( $this, 'form_field_city' ), 10, 4 );
//js scripts
add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
}
public function billing_fields( $fields, $country ) {
$fields['billing_city']['type'] = 'city';
return $fields;
}
public function shipping_fields( $fields, $country ) {
$fields['shipping_city']['type'] = 'city';
return $fields;
}
public function get_cities( $cc = null ) {
if ( empty( $this->cities ) ) {
$this->load_country_cities();
}
if ( ! is_null( $cc ) ) {
return isset( $this->cities[ $cc ] ) ? $this->cities[ $cc ] : false;
} else {
return $this->cities;
}
}
public function load_country_cities() {
global $cities;
// Load only the city files the shop owner wants/needs.
$allowed = array_merge( WC()->countries->get_allowed_countries(), WC()->countries->get_shipping_countries() );
if ( $allowed ) {
foreach ( $allowed as $code => $country ) {
if ( ! isset( $cities[ $code ] ) && file_exists( $this->get_plugin_path() . '/cities/' . $code . '.php' ) ) {
include( $this->get_plugin_path() . '/cities/' . $code . '.php' );
}
}
}
$this->cities = apply_filters( 'wc_city_select_cities', $cities );
}
public function form_field_city( $field, $key, $args, $value ) {
// Do we need a clear div?
if ( ( ! empty( $args['clear'] ) ) ) {
$after = '<div class="clear"></div>';
} else {
$after = '';
}
// Required markup
if ( $args['required'] ) {
$args['class'][] = 'validate-required';
$required = ' <abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
} else {
$required = '';
}
// Custom attribute handling
$custom_attributes = array();
if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
}
}
// Validate classes
if ( ! empty( $args['validate'] ) ) {
foreach( $args['validate'] as $validate ) {
$args['class'][] = 'validate-' . $validate;
}
}
// field p and label
$field = '<p class="form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $args['id'] ) . '_field">';
if ( $args['label'] ) {
$field .= '<label for="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) .'">' . $args['label']. $required . '</label>';
}
// Get Country
$country_key = $key == 'billing_city' ? 'billing_country' : 'shipping_country';
$current_cc = WC()->checkout->get_value( $country_key );
$state_key = $key == 'billing_city' ? 'billing_state' : 'shipping_state';
$current_sc = WC()->checkout->get_value( $state_key );
// Get country cities
$cities = $this->get_cities( $current_cc );
if ( is_array( $cities ) ) {
$field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="city_select ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '">
<option value="">'. __( 'Select an option&hellip;', 'woocommerce' ) .'</option>';
if ( $current_sc && $cities[ $current_sc ] ) {
$dropdown_cities = $cities[ $current_sc ];
} else if ( is_array( reset($cities) ) ) {
$dropdown_cities = array_reduce( $cities, 'array_merge', array() );
sort( $dropdown_cities );
} else {
$dropdown_cities = $cities;
}
foreach ( $dropdown_cities as $city_name ) {
$field .= '<option value="' . esc_attr( $city_name ) . '" '.selected( $value, $city_name, false ) . '>' . $city_name .'</option>';
}
$field .= '</select>';
} else {
$field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
}
// field description and close wrapper
if ( $args['description'] ) {
$field .= '<span class="description">' . esc_attr( $args['description'] ) . '</span>';
}
$field .= '</p>' . $after;
return $field;
}
public function load_scripts() {
if ( is_cart() || is_checkout() || is_wc_endpoint_url( 'edit-address' ) ) {
$city_select_path = $this->get_plugin_url() . 'assets/js/city-select.js';
wp_enqueue_script( 'wc-city-select', $city_select_path, array( 'jquery', 'woocommerce' ), self::VERSION, true );
$cities = json_encode( $this->get_cities() );
wp_localize_script( 'wc-city-select', 'wc_city_select_params', array(
'cities' => $cities,
'i18n_select_city_text' => esc_attr__( 'Select an option&hellip;', 'woocommerce' )
) );
}
}
public function get_plugin_path() {
if ( $this->plugin_path ) {
return $this->plugin_path;
}
return $this->plugin_path = plugin_dir_path( __FILE__ );
}
public function get_plugin_url() {
if ( $this->plugin_url ) {
return $this->plugin_url;
}
return $this->plugin_url = plugin_dir_url( __FILE__ );
}
}
$GLOBALS['wc_city_select'] = new WC_City_Select();
}
+82
View File
@@ -0,0 +1,82 @@
# Woo Viet - WooCommerce for Vietnam
| Name | Value |
|:---|:---|
| Contributors | htdat |
|Tags| WooCommerce Vietnam, vietnam, vietnamese, vietnam provinces, paypal for vietnam dong, vnd, vietnam dong, vietnam currency, vietnam customization |
| Requires at least | 4.3 |
| Tested up to | 4.7 |
| Stable tag | 1.2 |
| License | GPLv2 or later |
| License URI | https://www.gnu.org/licenses/gpl-2.0.html |
Add features to WooCommerce stores having anything related to Vietnam: currency, shipping address, PayPal and more.
## Description
**"Woo Viet - WooCommerce for Vietnam" brings the features that help to run WooCommerce stores and customize them for Vietnam much easier.**
Xem phiên bản tiếng Việt tại đây https://vi.wordpress.org/plugins/woo-viet/
## FEATURES
* Change the VND currency symbol `đ` to anything, e.g: `VND`, `VNĐ`, `đồng`, etc.
* Add provinces for Vietnam when visitors select Vietnam as a country of the shipping (billing) address. This is not available in WooCommerce by default.
* Convert `000` of prices to `K` (or anything). E.g: `50000` (VND) will be `50K` (VND), or `50 thousand` (VND).
* Support `VND` for [the PayPal Standard gateway](https://docs.woocommerce.com/document/paypal-standard/). Convert `VND` prices to any PayPal supported currency before sending visitors to the PayPal pages.
## ROAD MAP
In the future, this plugin will add more and more features for the Vietnam market:
* Integrate all districts to Vietnam provinces.
* Integrate at least one solution for collecting money by phone cards.
* Integrate the Vietnam payment gateways like 1Pay, OnePay, BaoKim, Ngan Luong, etc.
* Integrate the Vietnam shipping solutions like ShipChung, Giaohangnhanh, ViettelPost, etc.
## WHERE CAN I CONTRIBUTE MY CODE OR IDEA?
* You can report bugs or contribute code on [this GitHub repo](https://github.com/htdat/woo-viet).
* Please also do let us know if the "bug" is just a grammar/spelling error in both English and Vietnamese. We try to make our products as perfect as possible.
## INSTALLATION
Follow these steps to install and use the plugin:
1. Upload the plugin files to the `/wp-content/plugins/woo-viet` directory, or install the plugin through the WordPress plugins screen directly.
1. Activate the plugin through the `Plugins` screen in WordPress.
1. Go to the `WooCommerce -> Woo Viet` screen and configure the plugin.
## Installation
Follow these steps to install and use the plugin:
1. Upload the plugin files to the `/wp-content/plugins/woo-viet` directory, or install the plugin through the WordPress plugins screen directly.
1. Activate the plugin through the 'Plugins' screen in WordPress.
1. Go to the `WooCommerce -> Woo Viet` screen and configure the plugin.
## Frequently Asked Questions
### WHERE CAN I CONTRIBUTE MY CODE OR IDEA?
* You can report bugs or contribute code on [this GitHub repo](https://github.com/htdat/woo-viet).
* Please also do let us know if the "bug" is just a grammar/spelling error in both English and Vietnamese. We try to make our products as perfect as possible.
## Screenshots
1. The settings page under WooCommerce -> Woo Viet.
2. Prices are changed to "K", and the symbol is now "VND".
3. List provinces when selecting Vietnam.
4. Let clients know about the currency conversion before switching to the PayPal pages.
## Changelog
### 1.1
* Replace all “WooCommerce for Vietnam” to “Woo Viet”
* Replace all “woocomerce-for-vietnam” to “woo-viet”
* Re-upload to WordPress.org
### 1.0
* First release.
* Upload to WordPress.org
+18 -19
View File
@@ -2,8 +2,8 @@
Contributors: htdat
Tags: WooCommerce Vietnam, vietnam, vietnamese, vietnam provinces, paypal for vietnam dong, vnd, vietnam dong, vietnam currency, vietnam customization
Requires at least: 4.3
Tested up to: 4.7
Stable tag: 1.1
Tested up to: 4.7.2
Stable tag: 1.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -11,32 +11,23 @@ Add features to WooCommerce stores having anything related to Vietnam: currency,
== Description ==
**Woo Viet brings the features that help to run WooCommerce stores and customize them for Vietnam much easier.**
**"Woo Viet - WooCommerce for Vietnam" brings the features that help to run WooCommerce stores and customize them for Vietnam much easier.**
**Woo Viet đem đến các chức năng để site WooCommerce có thể dễ dàng tuỳ biến cho thị trường Việt Nam.**
Xem phiên bản tiếng Việt tại đây https://vi.wordpress.org/plugins/woo-viet/
= CHỨC NĂNG - FEATURES =
**(Tiếng Việt)**
* Đổi ký hiệu ngôn ngữ của VND từ mặc định `đ` sang bất cứ thừ gì khác, ví dụ: `VND`, `VNĐ`, `đồng`, v.v.
* Thêm tỉnh thành cho Việt Nam khi khách hiền điền địa chỉ nhận hàng hoặc nhận hoá đơn. Chức năng này không có ở trong WooCommerce mặc định.
* Đổi các số `000` trong giá cả thành `K` (hoặc bất cứ từ nào khác). Ví dụ: `50000` (VND) thành `50K` (VND), hay `50 nghìn` (VND).
* Hỗ trợ `VND` cho [cổng thanh toán PayPal Standard](https://docs.woocommerce.com/document/paypal-standard/). Chuyển đổi các giá `VND` sang bất kỳ loại tiền tệ nào mà PayPal hỗ trợ trước khi chuyển người dùng sang PayPal.
**(English)**
= FEATURES =
* Change the VND currency symbol `đ` to anything, e.g: `VND`, `VNĐ`, `đồng`, etc.
* Add provinces for Vietnam when visitors select Vietnam as a country of the shipping (billing) address. This is not available in WooCommerce by default.
* Add districts to Vietnam provinces.
* Convert `000` of prices to `K` (or anything). E.g: `50000` (VND) will be `50K` (VND), or `50 thousand` (VND).
* Support `VND` for [the PayPal Standard gateway](https://docs.woocommerce.com/document/paypal-standard/). Convert `VND` prices to any PayPal supported currency before sending visitors to the PayPal pages.
= ROAD MAP =
In the future, this plugin will be added more and more features for the Vietnam market:
In the future, this plugin will add more and more features for the Vietnam market:
* Integrate all districts to Vietnam provinces.
* Integrate all districts to Vietnam provinces. (available since 1.2)
* Integrate at least one solution for collecting money by phone cards.
* Integrate the Vietnam payment gateways like 1Pay, OnePay, BaoKim, Ngan Luong, etc.
* Integrate the Vietnam shipping solutions like ShipChung, Giaohangnhanh, ViettelPost, etc.
@@ -79,11 +70,19 @@ Follow these steps to install and use the plugin:
== Changelog ==
= 1.2 - 2017.03.03 =
* Integrate all districts to Vietnam provinces. Credits: [WC City Select by 8manos](https://github.com/8manos/wc-city-select) and [the Vietnam district data by 10h30](https://github.com/htdat/woo-viet/issues/4#issuecomment-277449462)
= 1.1 =
* Replace all “WooCommerce for Vietnam” to “Woo Viet”
* Replace all “woocomerce-fo-vietnam” to “woo-viet”
* Replace all “woocomerce-for-vietnam” to “woo-viet”
* Re-upload to WordPress.org
= 1.0 =
* First release.
* Upload to WordPress.org
* Upload to WordPress.org
== Upgrade Notice ==
= 1.2 =
The new version 1.2 comes with the feature "Add districts to Vietnam provinces".
+16 -4
View File
@@ -1,13 +1,13 @@
<?php
/**
* Plugin Name: Woo Viet
* Plugin Name: Woo Viet - WooCommerce for Vietnam
* Plugin URI: https://github.com/htdat/woo-viet
* Description: This plugin provides features and integrations specifically for Vietnam.
* Author: htdat
* Author URI: https://profiles.wordpress.org/htdat
* Text Domain: woo-viet
* Domain Path: /languages
* Version: 1.1
* Version: 1.2
* License: GPLv2+
*/
@@ -40,6 +40,10 @@ class WooViet {
array(
'enabled' => 'yes',
),
'add_city' =>
array(
'enabled' => 'yes',
),
'change_currency_symbol' =>
array(
'enabled' => 'yes',
@@ -112,7 +116,7 @@ class WooViet {
* @since 1.0
*/
public function i18n() {
load_plugin_textdomain( 'freshfunbits', false, basename( dirname( __FILE__ ) ) . '/languages/' );
load_plugin_textdomain( 'woo-viet', false, basename( dirname( __FILE__ ) ) . '/languages/' );
}
/**
@@ -133,6 +137,12 @@ class WooViet {
if ( 'yes' == $settings['add_province']['enabled'] ) {
include( WOO_VIET_DIR . 'inc/class-wooviet-provinces.php' );
$this->Provinces = new WooViet_Provinces();
// Enable "Add cities for Vietnam" if the province option is selected.
if ( 'yes' == $settings['add_city']['enabled'] ) {
include( WOO_VIET_DIR . 'inc/class-wooviet-cities.php' );
new WooViet_Cities();
}
}
include( WOO_VIET_DIR . 'inc/class-wooviet-currency.php' );
@@ -165,7 +175,9 @@ class WooViet {
* @return array
*/
static function get_settings() {
return get_option( 'woo-viet', self::$default_settings );
$settings = get_option( 'woo-viet', self::$default_settings );
$settings = wp_parse_args( $settings, self::$default_settings );
return $settings;
}
}