
How to replace states with neighborhoods in WooCommerce to sell only within a specific region
In many cases, online stores don’t need to sell across an entire country. For example, local businesses that only offer deliveries within a specific city or zone. A typical case in Argentina would be an online store that only delivers within Buenos Aires City (CABA). In this scenario, offering a list of provinces (as WooCommerce does by default in the billing_state
field) doesn’t make sense and can confuse customers.
What’s the solution?
The solution is simple: replace the list of provinces with a list of CABA neighborhoods. That way, WooCommerce will still use the billing_state
field, but its content will be much more relevant and clearer for the customer.
We’ll achieve this with a single WooCommerce filter (woocommerce_states
) and a small customization to the checkout field so it shows the label “Neighborhood” instead of “State/Province”.
Replace argentine states with CABA neighborhoods
This code replaces Argentina’s states with a list of neighborhoods in Buenos Aires City:
<?php add_filter( 'woocommerce_states', 'customReplaceStatesWithCabaNeighborhoods' ); function customReplaceStatesWithCabaNeighborhoods( $states ) { $states['AR'] = [ 'agronomia' => 'Agronomía', 'almagro' => 'Almagro', 'balvanera' => 'Balvanera', 'barracas' => 'Barracas', 'belgrano' => 'Belgrano', 'boedo' => 'Boedo', 'caballito' => 'Caballito', 'chacarita' => 'Chacarita', 'coghlan' => 'Coghlan', 'colegiales' => 'Colegiales', 'constitucion' => 'Constitución', 'flores' => 'Flores', 'floresta' => 'Floresta', 'la_boca' => 'La Boca', 'monserrat' => 'Monserrat', 'monte_castro' => 'Monte Castro', 'nunez' => 'Núñez', 'palermo' => 'Palermo', 'parque_avellaneda'=> 'Parque Avellaneda', 'parque_chacabuco' => 'Parque Chacabuco', 'parque_chas' => 'Parque Chas', 'pompeya' => 'Nueva Pompeya', 'puerto_madero' => 'Puerto Madero', 'recoleta' => 'Recoleta', 'retiro' => 'Retiro', 'saavedra' => 'Saavedra', 'san_cristobal' => 'San Cristóbal', 'san_nicolas' => 'San Nicolás', 'san_telmo' => 'San Telmo', 'villa_crespo' => 'Villa Crespo', 'villa_devoto' => 'Villa Devoto', 'villa_lugano' => 'Villa Lugano', 'villa_urquiza' => 'Villa Urquiza', 'villa_del_parque' => 'Villa del Parque', ]; return $states; }
Customize the checkout label
Next, let’s change the label of the billing_state
field in the checkout form so it displays “Neighborhood” instead of “State”:
<?php add_filter( 'woocommerce_checkout_fields', 'customRenameStateFieldToNeighborhood' ); function customRenameStateFieldToNeighborhood( $fields ) { $fields['billing']['billing_state']['label'] = 'Neighborhood'; return $fields; }
With these small changes:
- WooCommerce will still use the built-in
billing_state
field, ensuring compatibility with payment gateways, shipping logic, and validations. - Customers will see a dropdown list of CABA neighborhoods instead of provinces.
- The checkout form becomes clearer and more relevant for local-only businesses.
If your WooCommerce store only delivers within a specific region like Buenos Aires City, replacing states with neighborhoods is a quick and effective way to enhance the user experience. It keeps the checkout intuitive without needing to create custom fields or modify the database.