How can I add a state to the states in woocommerce

Viewed 27

I'm currently finishing up building my store and I need help adding a state that doesn't exist within Woocommerce's states dropdown list. My country is Egypt and the state I need to add is "6th of October" I know it's a php code I'm supposed to add but I don't really know what to write. Can anyone help please? Thank you so much! Bleb

1 Answers

You can try below code.

You must replace both instances of XX with your country code. This means each state id in the array must have your two letter country code before the number you assign to the state.

add_filter( 'woocommerce_states', 'custom_woocommerce_states' );

function custom_woocommerce_states( $states ) {

  $states['XX'] = array(
    'XX1' => 'State 1', 
    'XX2' => 'State 2'
  );

  return $states;
}

Related