Newly added districts on Woocommerce Shipping appears as new states not district
-
I am currently encountering some issues as regards shipping regions for woocommerce on an online store I am working on. Its well established that Woocommerce core only has provisions for states or provinces within a country. I have been trying to breakdown these states to cities and districts. I got to a stage with a code, but the districts for the capital of my country, Abuja, are displaying as states under Nigeria, and not as districts under the capital in the dropdown of shipping regions under Nigeria. I am seeking assistance on how to tweak the code to make the the districts and cities of states and Abuja, to be under their various states and not as a standalone state under Nigeria. Keen for the newly added districts to appear under their respective states at the Cart/checkout pages, and as additional state as its currently showing
Please, find the below more details from screenshot links and the code I usedhttps://tinyurl.com/yy94ufgt (Four of Nigeria’s 36 states on woocommerce core)
https://tinyurl.com/yxtwywmk (the places I added that are appearing as states that I want as districts under the Capital, Abuja)
https://tinyurl.com/y3a324f3 (the code snippet)The code I used is this
add_filter( ‘woocommerce_states’, ‘adding_custom_country_states’ );
function adding_custom_country_states( $states ) {// Define the related country code
$country_code = ‘NG’;// Define for each state a different state code
$new_states = array(
‘FC1’ => __(‘Wuse’, ‘woocommerce’),
‘FC2’ => __(‘Maitama’, ‘woocommerce’),
‘FC3’ => __(‘Wuye’, ‘woocommerce’),
‘FC4’ => __(‘Asokoro’, ‘woocommerce’),
);// Merge existing states with the new states
$states[$country_code] += $new_states;return $states;
The page I need help with: [log in to see the link]
- The topic ‘Newly added districts on Woocommerce Shipping appears as new states not district’ is closed to new replies.