City/State missing location

WordPress Business Themes Forums Responsive Themes Auction Theme City/State missing location

Discontinued - The forum content is out of date. For theme support please use our support desk here.

City/State missing location

April 23, 2019
 ppt_joe21-04-19_94248267

  • ppt_joe21-04-19_94248267
    Newbie 0 points

    Hey
    How can I add more states/cities to the account details drop down menu? The options currently available are all wrong.
    Cheers,

    April 23, 2019 at 10:15 pm
  • JamesD
    JamesD
    Super Guru 1,351 points

    @ppt_joe21-04-19_94248267
    I don’t believe there’s anything built-in to do this.

    If you’re comfortable working with code then Ithismight be able to help you get started. This function will allow you to add additional city/states to the current list of states and re-alphabetize them.

    Note: Make sure you change the new states accordingly. This will update the global variable that holds the states. Be sure to test it thoroughly as well.

    function custom_states_init() {
        if( isset($GLOBALS['core_state_list'])) {
            // Get all CORE pre-set states
            $aStates = $GLOBALS['core_state_list'];
    
            // Set the City/State by 2 character country code IN CAPS.
            $aStatesAdd = array(
                // 'GB' is the country code for the United Kingdom
                'GB' =>
                    array( 'A First New United Kingdom State',
                         'A Second New United Kingdom State'
                    ),
                // 'US' is the country code for the USA
                'US' =>
                    array( 'A First New USA State',
                         'A Second New USA State'
                ),
            );
            if(!isset($aStatesAdd) || empty($aStatesAdd)) { return; }
            foreach ($aStatesAdd as $key=>$val) {
                if(is_array($val)) {
                    $str = $aStates[$key];
                    $str .= '|' . implode('|', $val);
                    $aTmp = explode('|', $str);
    
                    // Sort new arrays
                    sort($aTmp);
                    // Update state with new values
                    $aStates[$key] = implode('|', $aTmp);
                }
            }
            // Change state values with new data
            $GLOBALS['core_state_list'] = $aStates;
        }
    }
    add_action('init', 'custom_states_init');
    April 25, 2019 at 7:10 am
Viewing 2 posts - 1 through 2 (of 2 total)

Didn't find what you were after?

Chat with us now

or contact our support team