Skip to content

Instantly share code, notes, and snippets.

@geektutor
Created December 13, 2018 11:17
Show Gist options
  • Save geektutor/af7a83f80a2e77e95df7c78ea4d3f27c to your computer and use it in GitHub Desktop.
Save geektutor/af7a83f80a2e77e95df7c78ea4d3f27c to your computer and use it in GitHub Desktop.
add_filter('woocommerce_states', 'add_custom_states_to_country',70);
add_filter('woocommerce_countries_allowed_country_states', 'add_custom_states_to_country');
function add_custom_states_to_country( $states ) {
$country_code = 'NG';
$new_states = array(
'AA' => __('Abraham Adesanya', 'woocommerce'),
'AR' => __('Ado Road', 'woocommerce'),
'AG' => __('Agege', 'woocommerce'),
'AJ' => __('Ajah', 'woocommerce'),
'AO' => __('Amuwo Odofin', 'woocommerce'),
'AP' => __('Apapa', 'woocommerce'),
'AN' => __('Apongbon', 'woocommerce'),
'AY' => __('Ayobo', 'woocommerce'),
'BD' => __('Badore', 'woocommerce'),
'CV' => __('Chevron', 'woocommerce'),
'CM' => __('CMS', 'woocommerce'),
'EG' => __('Egbeda', 'woocommerce'),
'FE' => __('Festac', 'woocommerce'),
'GB' => __('Gbagada', 'woocommerce'),
'IE' => __('Igbo-Efon', 'woocommerce'),
'ID' => __('Idimu', 'woocommerce'),
'IJ' => __('Ijegun', 'woocommerce'),
'IU' => __('Iju', 'woocommerce'),
'IK' => __('Ikeja', 'woocommerce'),
'IO' => __('Ikorodu', 'woocommerce'),
'IY' => __('Ikoyi', 'woocommerce'),
'IL' => __('Ilupeju', 'woocommerce'),
'IP' => __('Ipaja', 'woocommerce'),
'IS' => __('Isheri', 'woocommerce'),
'IT' => __('Isolo', 'woocommerce'),
'JK' => __('Jakande', 'woocommerce'),
'LK' => __('Lakwe', 'woocommerce'),
'LG' => __('Lekki Garden Estate', 'woocommerce'),
'LI' => __('Lekki Phase I', 'woocommerce'),
'LT' => __('Lekki Phase II', 'woocommerce'),
'MI' => __('Magodo Phase I', 'woocommerce'),
'MT' => __('Magodo Phase II', 'woocommerce'),
'MR' => __('Marina', 'woocommerce'),
'MU' => __('Mushin', 'woocommerce'),
'NT' => __('Navy Town', 'woocommerce'),
'OB' => __('Obalende', 'woocommerce'),
'OG' => __('Ogba', 'woocommerce'),
'OK' => __('Okota', 'woocommerce'),
'OS' => __('Oshodi', 'woocommerce'),
'SG' => __('Sangotedo', 'woocommerce'),
'ST' => __('Satellite Town', 'woocommerce'),
'SU' => __('Surulere', 'woocommerce'),
'VG' => __('VGC', 'woocommerce'),
'VI' => __('Victoria Island', 'woocommerce'),
'YB' => __('Yaba', 'woocommerce')
);
$states[$country_code] += $new_states;
return $states;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment