
Enable WooCommerce Checkout State Selection Field
WooCommerce as a shop system comes from the international market. States, cantons, or regions within a country are normally only provided by the system for the USA in WordPress/WooCommerce. If you want to use WooCommerce in German for Germany, Austria, or Switzerland and want states at checkout as a selection field, you cannot avoid writing a few lines of code. Unfortunately, WooCommerce Germanized and German Market do not help with this either.
Simply display the state selection field in WooCommerce checkout
The following code simply needs to be placed in the functions.php of the theme or child theme. Alternatively, the free plugin „Code Snippets“ offers a safe and easy way to embed such additional functions without downtime.
// ENABLE STATE FIELD
add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
function custom_woocommerce_states( $states ) {
$states['DE'] = array(
'BW' => 'Baden-Württemberg',
'BY' => 'Bavaria',
'BE' => 'Berlin',
'BB' => 'Brandenburg',
'HB' => 'Bremen',
'HH' => 'Hamburg',
'HE' => 'Hesse',
'MV' => 'Mecklenburg-Vorpommern',
'NI' => 'Lower Saxony',
'NW' => 'North Rhine-Westphalia',
'RP' => 'Rhineland-Palatinate',
'SL' => 'Saarland',
'SN' => 'Saxony',
'ST' => 'Saxony-Anhalt',
'SH' => 'Schleswig-Holstein',
'TH' => 'Thuringia'
);
return $states;
}
| BW | Baden-Württemberg |
| BY | Bavaria |
| BE | Berlin |
| BB | Brandenburg |
| HB | Bremen |
| HH | Hamburg |
| HE | Hesse |
| MV | Mecklenburg-Vorpommern |
| NI | Lower Saxony |
| NW | North Rhine-Westphalia |
| RP | Rhineland-Palatinate |
| SL | Saarland |
| SN | Saxony |
| ST | Saxony-Anhalt |
| SH | Schleswig-Holstein |
| TH | Thuringia |
As a WooCommerce agency we offer comprehensive WordPress help and support at a fair price.


