Skip to content

Instantly share code, notes, and snippets.

@rememberlenny
Created December 17, 2012 07:16
Show Gist options
  • Save rememberlenny/4316395 to your computer and use it in GitHub Desktop.
Save rememberlenny/4316395 to your computer and use it in GitHub Desktop.
WooCommerece: Adding China's Provinces to shipping locations. Snippet should go in child-theme's functions.php.
/**
* Code goes in functions.php or a custom plugin. Replace XX with the country code your changing.
*/
add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
function custom_woocommerce_states( $states ) {
$states['CN'] = array(
'CN1' => 'Yunnan / 云南',
'CN2' => 'Beijing / 北京',
'CN3' => 'Tianjin / 天津',
'CN4' => 'Hebei / 河北',
'CN5' => 'Shanxi / 山西',
'CN6' => 'Inner Mongolia / 內蒙古',
'CN7' => 'Liaoning / 辽宁',
'CN8' => 'Jilin / 吉林',
'CN9' => 'Heilongjiang / 黑龙江',
'CN10' => 'Shanghai / 上海',
'CN11' => 'Jiangsu / 江苏',
'CN12' => 'Zhejiang / 浙江',
'CN13' => 'Anhui / 安徽',
'CN14' => 'Fujian / 福建',
'CN15' => 'Jiangxi / 江西',
'CN16' => 'Shandong / 山东',
'CN17' => 'Henan / 河南',
'CN18' => 'Hubei / 湖北',
'CN19' => 'Hunan / 湖南',
'CN20' => 'Guangdong / 广东',
'CN21' => 'Guangxi Zhuang / 广西壮族',
'CN22' => 'Hainan / 海南',
'CN23' => 'Chongqing / 重庆',
'CN24' => 'Sichuan / 四川',
'CN25' => 'Guizhou / 贵州',
'CN26' => 'Shaanxi / 陕西',
'CN27' => 'Gansu / 甘肃',
'CN28' => 'Qinghai / 青海',
'CN29' => 'Ningxia Hui / 宁夏',
'CN30' => 'Macau / 澳门',
'CN31' => 'Tibet / 西藏',
'CN32' => 'Xinjiang / 新疆'
);
return $states;
}
@yangshaobo
Copy link

I added this snippet in my theme's function.php, but in the "Thanks You" page, the billing information section still shown the states such as "CN2","CN5" . Any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment