Skip to content

Instantly share code, notes, and snippets.

@rynaldos
Created January 25, 2023 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rynaldos/8daadb490b44a667fc8b9ed30f5fd968 to your computer and use it in GitHub Desktop.
Save rynaldos/8daadb490b44a667fc8b9ed30f5fd968 to your computer and use it in GitHub Desktop.
Zimbabwe city extension for checkout page and shipping zones in WooCommerce
add_filter( 'woocommerce_countries', 'rs_edit_zw_country' );
function rs_edit_zw_country ( $countries ) {
$new_countries = array(
'ZW' => __( 'Zimbabwe', 'woocommerce' ),
);
return array_merge( $countries, $new_countries );
}
add_filter( 'woocommerce_continents', 'rs_add_new_zw_country_to_continents' );
function rs_add_new_zw_country_to_continents ( $continents ) {
$continents['AF']['countries'][] = 'ZW';
return $continents;
}
add_filter( 'woocommerce_states', 'custom_wc_states_zw' );
function custom_wc_states_zw ( $states ) {
$states['ZW'] = array(
'Harare' => 'Harare',
'Bulawayo' => 'Bulawayo',
'Chitungwiza' => 'Chitungwiza',
'Mutare' => 'Mutare',
'Epworth' => 'Epworth',
'Gweru' => 'Gweru',
'Kwekwe' => 'Kwekwe',
'Kadoma' => 'Kadoma',
'Masvingo' => 'Masvingo',
'Chinhoyi' => 'Chinhoyi',
'Norton' => 'Norton',
'Marondera' => 'Marondera',
'Ruwa' => 'Ruwa',
'Chegutu' => 'Chegutu',
'Zvishavane' => 'Zvishavane',
'Bindura' => 'Bindura',
'Beitbridge' => 'Beitbridge',
'Redcliff' => 'Redcliff',
'Victoria Falls' => 'Victoria Falls',
'Hwange' => 'Hwange',
'Rusape' => 'Rusape',
'Chiredzi' => 'Chiredzi',
'Kariba' => 'Kariba',
'Karoi' => 'Karoi',
'Chipinge' => 'Chipinge',
'Gokwe' => 'Gokwe',
'Shurugwi' => 'Shurugwi',
);
return $states;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment