Cities Shipping Zones for WooCommerce

Which uses shop owners make with the customer city?

  • Set shipping rates per cities
  • Sales stats by city (Dashbaord => WooCommerce => Reports => Sales by city)
  • Display cities shipping calculator with the shortcode [csz_cities]
  • Sell certain products per city (with plugin that limits by state)
  • Ship certain products per city (associating the products to a class without price in shipping method, if calculation type is by order the base cost should be empty as well)
  • Set products prices by customer city (with discounts plugin that has state based option)
  • Apply taxes per city (use the city code in the state field of the tax settings)
  • Enable payment / shipping methods per city (with conditional payment / shipping plugin)
  • Set Shipping days per city (with order delivery date plugin that support shipping zone restrictions)
  • Set minimum order amount per city (with order minimum amount plugin that support shipping zone restrictions)
  • Display to the user certain information by the selected city (with the woocommerce_load_shipping_methods hook)
  • Display the cities in external checkout page (retreive the states via WooCommerce REST API)
Options

What is the State Autofill option?
When enabled, the state will be auto filled in the order details by the selected city for countries that have states in their cities list.

What is the Filters option?
When enabled, a state filter will be displayed for the store country in the checkout and in the shipping calculator. The state will not be inserted into the order details unless the ‘State Autofill’ option is enabled.

Bulk Edit Tool

What is the required format?
Semicolon (;) between each city. For example: Wien; Rust; Steinbrunn

How to modify cities in list (which seperated by new line) to the required format?
Replace [\r\n]+ (regex) with ; in Notepad++.

Integrations

Why in the integrated software the city appear twice or the city code is present?
You will have to remove the sending of the state field (billing/shipping, orders/customers) via its plugin’s code for the countries you apply the plugin on.

Why in my integrated software the city field is empty or the payment failed?
You will have to modify its way of retreiving the city field (billing/shipping) from the order for the countries you apply the plugin on- from: $_POST['billing_city'] into $order->get_billing_city(). As alternative, add to the woocommerce_checkout_create_order action a command that copies $order->get_billing_city() into $_POST['billing_city'].

How to export customers’ address?
Create action that erase/populate the state name from the selected city.

Why the state code and not the state name appears in the order details in the first order email confirmation and in the my account section while using the State Autofill option on countries with WooCommerce built-in states list?
You can use the woocommerce_formatted_address_replacements filter to fix it.

How to prevent the loading of the cities in WCFM plugin pages?

add_filter( 'csz_enable_cities', 'csz_disable_cities_wcfm' );
add_filter( 'woocommerce_states', 'csz_load_states_wcfm', 9999 );

function csz_disable_cities_wcfm( $cities_enabled ) {
	return isset( $_GET['store-setup'] ) && 'yes' === $_GET['store-setup'] || false !== strpos( $_SERVER['REQUEST_URI'], 'store-manager' ) ? false : $cities_enabled;
}

function csz_load_states_wcfm( $states ) {
	if ( isset( $_GET['store-setup'] ) && 'yes' === $_GET['store-setup'] || false !== strpos( $_SERVER['REQUEST_URI'], 'store-manager' ) ) {
		foreach ( get_option( 'wc_csz_countries_codes' ) as $country_code ) {
			include( WP_PLUGIN_DIR . '/cities-shipping-zones-for-woocommerce/i18n/cities/' . $country_code . '.php' );
			if ( $country_states ) {
				$states[ $country_code ] = $country_states;
			}
		}
	}
	return $states;
}

How to integrate with Food Online Premium plugin?
Prevent the customer state from beeing loaded in config_default_customer_address function and add to line 836 in class-fdoe-del.php file (update the mismatch cities names):

if ( is_plugin_active( 'cities-shipping-zones-for-woocommerce/cities-shipping-zones-for-woocommerce.php' ) && in_array( $country, get_option( 'wc_csz_countries_codes' ) ) ) {
	$cities = [
		'Talin' => 'Tallinn',
	];
	if ( isset( $cities[ $_POST['city'] ] ) ) {
		$_POST['city'] = $cities[ $_POST['city'] ];
	}
	$state = array_search( _x( wc_clean( $_POST['city'] ), "{$country}-cities", 'cities-shipping-zones-for-woocommerce' ), WC()->countries->get_states( $country ) );
	$_POST['city'] = '';
}

How to make the ‘Filters’ option compatible with the Checkout Manager for WooCommerce plugin?

add_filter( 'woocommerce_default_address_fields', 'wc_save_state_filter', 999 );
add_filter( 'wooccm_billing_fields', 'wc_update_billing_fields' );
add_filter( 'wooccm_shipping_fields', 'wc_update_shipping_fields' );

function wc_save_state_filter( $fields ) {
	if ( isset( $fields['new_state'] ) && is_checkout() ) {
		$_GET['new_state'] = $fields['new_state'];
	}
	return $fields;
}

function wc_update_billing_fields( $fields ) {
	if ( is_checkout() ) {
		$_GET['new_state']['key'] = 'billing_new_state';
		$fields[ array_search( 'billing_city', array_column( $fields, 'key' ) ) ] = wc_clean( $_GET['new_state'] );
	}
	return $fields;
}

function wc_update_shipping_fields( $fields ) {
	if ( is_checkout() ) {
		$_GET['new_state']['key'] = 'shipping_new_state';
		$fields[ array_search( 'shipping_city', array_column( $fields, 'key' ) ) ] = wc_clean( $_GET['new_state'] );
	}
	return $fields;
}
Cities List

How to translate the cities names?
With the built-in WordPress editor (contact if the cities are absent or if you have ready-made translation), you can filter only your country cities by the context attribute (for example for Estonia use EE-cities), when you finish export it to the plugin /i18n/languages/ path.

How to modify cities names?
Update countries codes, and cities codes and names (add the state prefix if using the Filters option):

add_filter( 'csz_cities', 'csz_modify_cities_names' );
function csz_modify_cities_names( $cities ) {
	$country = 'EE';
	$cities_names = [
		'EE784'	=> 'Talin',
		'EE296'	=> 'Keilalinn',
	];
	foreach ( $cities_names as $key => $city ) {
		if ( isset( $cities[ $country ][ $key ] ) ) {
			$cities[ $country ][ $key ] = $city;
		}
	}
	return $cities;
}

How to remove some cities from the list?
Update country code and cities codes:

add_filter( 'csz_cities', 'csz_remove_cities' );
function csz_remove_cities( $cities ) {
	$country_code = 'EE';
	$unnecessary_cities = [ 'EE784', 'EE296', 'EE446' ];
	foreach ( $unnecessary_cities as $city ) {
		if ( isset( $cities[ $country_code ][ $city ] ) ) {
			unset( $cities[ $country_code ][ $city ] );
		}
	}
	return $cities;
}

How to keep only specific cities in the list?
Update country code and cities codes:

add_filter( 'csz_cities', 'csz_set_cities' );
function csz_set_cities( $cities ) {
	$country = 'EE';
	$keep_cities = [ 'EE784', 'EE296', 'EE446' ];
	$new_cities = [];
	foreach ( $keep_cities as $city ) {
		if ( isset( $cities[ $country ][ $city ] ) ) {
			$new_cities[ $city ] = $cities[ $country ][ $city ];
		}
	}
	$cities[ $country ] = $new_cities;
	return $cities;
}

How to remove from the list all the cities of certain states?
Update states codes:

add_filter( 'csz_states', 'csz_remove_states_cities' );
function csz_remove_states_cities( $states ) {
	$unnecessary_states = [ 'EE001', 'EE004', 'EE006' ];
	foreach ( $unnecessary_states as $state_code ) {
		if ( isset( $states[ $state_code ] ) ) {
			unset( $states[ $state_code ] );
		}
	}
	return $states;
}

How to keep in the list only the cities from certain states (not compatible with international stores)?
Update states codes:

add_filter( 'csz_states', 'csz_set_states' );
function csz_set_states( $states ) {
	$keep_states = [ 'EE001', 'EE004', 'EE006' ];
	$new_states = [];
	foreach ( $keep_states as $state ) {
		if ( isset( $states[ $state ] ) ) {
			$new_states[ $state ] = $states[ $state ];
		}
	}
	return $new_states;
}

How to create shipping zones for quarters inside a city?
Create shipping zone with that city and restrict to the relevant postcodes, or (not compatible with the State Autofill / Filters options and 3-party integrations) split the city into areas (update country code and city code and areas names, if the store is located inside this city update the store location in WooCommerce settings):

add_filter( 'csz_cities', 'csz_split_cities' );
function csz_split_cities( $cities ) {
	$country_code = 'EE';
	$city_code = 'EE784';
	$sub_cities = [ __( 'Northern', 'woocommerce' ), __( 'Southern', 'woocommerce' ) ];
	if ( isset( $cities[ $country_code ][ $city_code ] ) ) {
		$count = 101;
		foreach ( $sub_cities as $sub_city ) {
			$cities[ $country_code ][ $city_code . $count ] = $cities[ $country_code ][ $city_code ] . ' - ' . $sub_city;
			$count++;
		}
		unset( $cities[ $country_code ][ $city_code ] );
	}
	return $cities;
}

How to let customers to select a city which is not exist in the list?
Temporary remove all the countries you apply the plugin on and remove all the saved states values of your current customers from those countries to prevent loading the state value in the city field (to make it compatible with the State Autofill option you must make the billing/shipping filter required when visible in cart and checkout and if a custom city was selected fill the order’s state by the filter field value):

add_filter( 'csz_enable_custom_city', '__return_true' );

How to move some cities to the top of the dropdown?
Update the country and cities codes:

add_filter( 'csz_sort_cities', '__return_false' );
add_filter( 'csz_cities', 'csz_cities_custom_order' );
function csz_cities_custom_order( $cities ) {
	$country = 'EE';
	$first_keys = [ 'EE726', 'EE890' ];
	$pre_arr = [];
	foreach ( $first_keys as $key ) {
		if ( isset( $cities[ $country ][ $key ] ) ) {
			$pre_arr[ $key ] = $cities[ $country ][ $key ];
		}
	}
	$cities[ $country ] = $pre_arr + $cities[ $country ];
	return $cities;
}

How to move some states to the top of the dropdown?
Update the states codes:

add_filter( 'csz_sort_states', '__return_false' );
add_filter( 'csz_states', 'csz_states_custom_order' );
function csz_states_custom_order( $states ) {
	$first_keys = [ 'EE007', 'EE004' ];
	$pre_arr = [];
	foreach ( $first_keys as $key ) {
		if ( isset( $states[ $key ] ) ) {
			$pre_arr[ $key ] = $states[ $key ];
		}
	}
	return $pre_arr + $states;
}

How to set different tax class per state?
Update the country, states codes and tax classes:

add_filter( 'woocommerce_product_get_tax_class', 'csz_change_tax_class', 10, 2 );
add_filter( 'woocommerce_product_variation_get_tax_class', 'csz_change_tax_class', 10, 2 );
function csz_change_tax_class( $tax_class, $product ) {
	$country = 'EE';
	$tax_classes = [
		'EE001' => 'Zero rate',
		'EE004'	=> 'Standard rate',
	];
	if ( $country === WC()->customer->get_shipping_country() && in_array( $country, get_option( 'wc_csz_countries_codes' ) ) ) {
		$city = WC()->customer->get_shipping_state();
		$country_cities = $country_states = '';
		include( WP_PLUGIN_DIR . '/cities-shipping-zones-for-woocommerce/i18n/cities/' . $country . '.php' );
		if ( isset( $country_states ) ) {
			foreach ( $country_states as $state_code => $state_name ) {
				if ( isset( $country_cities[ $state_code ][ $city ] ) ) {
					if ( isset( $tax_classes[ $state_code ] ) ) {
						return $tax_classes[ $state_code ];
					}
					break;
				}
			}
		}
	}
	return $tax_class;
}
Shortcode

How to display the shipping calculator shortocde message permanently (not compatible with multinational stores)?

add_filter( 'wp_footer', 'csz_custom_shipping_message' );
function csz_custom_shipping_message() { ?>
	<script type="text/javascript">
	jQuery( function( $ ) {
		$( document ).on( 'zone_matched', function( event, response ) {
			$( '#shipping_state-description' ).remove();
			if ( ! $( '#shipping_message' ).length ) {
				$( '#shipping_state_field' ).append( '<span id="shipping_message">response</span>' );
			}
			$( '#shipping_message' ).text( response ).css( { 'color':'black', 'background-color':'yellow' } );
		} );
	} );
	</script>
<?php }

How to display it on hover?

add_filter( 'wp_footer', 'csz_hover_shipping_message' );
function csz_hover_shipping_message() { ?>
	<script type="text/javascript">
	jQuery( function( $ ) {
		$( '#shipping_state_field' ).on( 'mouseover', function() {
			 $( '#shipping_state-description' ).show();
		} );
	} );
	</script>
<?php }

How to save the customer’s selection even before he adds to cart some items?
Use this code.

Distance Fee

How to apply distance fee?
Given a (domestic) city’s distances list, it will be possible to add distance based fee for the shipping rate or product price (for example- to sell moving services).

Why the tax is not calculated on the distance fee?
Enter in the shipping method cost greater than zero.

How I shall organize the distances list for some city?
Use as index the locations codes or names (as they appear in the dashboard and update $key_format), verify to set distance to the city itself, the distances should be greater than 0.

How to insert with the Bulk Edit tool all the locations within certain distance from a city with distances list?
Enter exclamation mark (!) followed by the city code, if necessary add minimum and maximum distance seperated by semicolon (;).

WooCommerce REST API
add_filter( 'woocommerce_rest_api_get_rest_namespaces', 'csz_states_api' );
function csz_states_api( $controllers ) {
	$controllers['wc/v3']['data-states'] = 'WC_REST_Data_States_Controller';
	return $controllers;
}

class WC_REST_Data_States_Controller extends WC_REST_Data_Controller {
	protected $namespace = 'wc/v3';
	protected $rest_base = 'data/states';
	function register_routes() {
		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<state>[\w-]+)/zone', [
			'methods'		=> 'GET',
			'callback'		=> [ $this, 'get_zone' ],
			'args'			=> [ 'state' => [ 'description' => __( 'State / County', 'woocommerce' ), 'type' => 'string' ] ],
			'permission_callback'	=> [ $this, 'get_items_permissions_check' ],
		] );
		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<state>[\w-]+)/state', [
			'methods'		=> 'GET',
			'callback'		=> [ $this, 'get_state' ],
			'args'			=> [ 'state' => [ 'description' => __( 'State / County', 'woocommerce' ), 'type' => 'string' ] ],
			'permission_callback'	=> [ $this, 'get_items_permissions_check' ],
		] );
	}
	function get_zone( $data ) {
		return [ 'id' => wc_get_shipping_zone( [ 'destination' => [ 'country' => substr( $data['state'], 0, 2 ), 'state' => $data['state'], 'postcode' => '' ] ] )->get_zone_id() ];
	}
	function get_state( $data ) {
		foreach ( get_option( 'wc_csz_countries_codes' ) as $country_code ) {
			$country_cities = $country_states = '';
			include( WP_PLUGIN_DIR . '/cities-shipping-zones-for-woocommerce/i18n/cities/' . $country_code . '.php' );
			if ( isset( $country_states ) ) {
				foreach ( $country_states as $state_code => $state_name ) {
					if ( isset( $country_cities[ $state_code ][ $data['state'] ] ) ) {
						return $country_states[ $state_code ];
					}
				}
			}
		}
		return false;
	}
}

How to retrieve the shipping zone a city belong to (for the countries the plugin apply on)?

/wp-json/wc/v3/data/states/<city_code>/zone

How to retrieve the state name a city belong to (for the countries the plugin apply on)?

/wp-json/wc/v3/data/states/<city_code>/state
Uninstall Plugin / Countries / Locations
  • WooCommerce Shipping Zones settings: Remove the locations (you can use the Bulk Edit tool)
  • Plugin Settings: Remove the countries
  • WooCommerce General Settings: Update the store location country / state
  • Users: convert/erase the state field values of users that were created/updated while the plugin was applied on the countries they belong to
  • Plugins: Deactivate and delete the plugin

175 comments

  1. Hi,

    I was trying to use your “Cities Shipping Zones for WooCommerce” plugin. However, the country I am trying to use this plugin is not supported. I would to request to add “United Arab Emirates” to the supported countries.

    Thank you in advance.

    1. Raditya, Indonesia is supported but the address format in Indonesia contains states, so if you use the plugin you will not able to integrate your website with online payment or shipping software.

      1. That’s a bummer! Guess I’ll have to add them by zip codes, which is a lot of work to do. Thanks for the fast reply and wish you have a great day!

        1. Hi, in the latest plugin update the ‘autofill state’ option was added, when enabled the integration with online payment and shipping software should function as usual.

  2. Dear, please help on following
    1. could you please add Myanmar as a supported country
    2. how to add different cities in Myanmar, where shipping zone applies as customer enters the city at check out page.

    Thank you

    1. Myanmar will be added in the next release. Once its added, you will be able to select cities in the Shipping Zones edit screen (Dashboard => WooCommerce => Settings => Shipping)

  3. Excellent complement!
    Congratulations

    I have seen “How to modify cities names?”, it could be a solution but I don’t know what the city codes of my country / state are

    Can I just add a city?
    Where can I get the country / city codes to modify them?

    Thanks!

  4. Hi,

    I was trying to use your “Cities Shipping Zones for WooCommerce” plugin. However, the country I am trying to use this plugin is not supported. I would to request to add “Morocco” to the supported countries.

    Thank you in advance.

    1. Hi Krishneel, Fiji is better organized by its provinces so no need to use the plugin just add this to your theme’s functions.php file:
      add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
      function custom_woocommerce_states( $states ) {
      $states['FJ'] = [
      'FJ01' => 'Ba',
      'FJ02' => 'Bua',
      'FJ03' => 'Cakaudrove',
      'FJ04' => 'Kadavu',
      'FJ05' => 'Lau',
      'FJ06' => 'Lomaiviti',
      'FJ07' => 'Macuata',
      'FJ08' => 'Nadroga and Navosa',
      'FJ09' => 'Naitasiri',
      'FJ10' => 'Namosi',
      'FJ11' => 'Ra',
      'FJ12' => 'Rewa',
      'FJ13' => 'Serua',
      'FJ14' => 'Tailevu',
      ];
      return $states;
      }

    1. Hi, make sure Sri Lanka was selected in the plugin settings ‘Country / Region’ field (‘The countries to apply the plugin on’), in WooCommerce Shipping Settings click edit on the first shipping zone and insert some cities of Sri Lanka in its ‘Zone regions’ field.

      1. Some Cities are not listed for Srilanka How to add it?
        I hope you can make some coding to add the missing cities in the Backend

        At now Please help me to add some city names
        And for feature updates Kindly Refer the city names in daraz.lk

    1. Hi Obinna, After you have selected Nigeria via the plugin settings, go to shipping zone edit screen (Dashboard => WooCommerce => Settings => Shipping) and select the cities in the Zone regions field.

  5. I’m having some issues while integrating with cybersource, and I need to be able to set the “state” to the same as “country” (as cybersoruce support indicated) so, can you please help me to achieve this?

    1. Hi, can you provide more details? the state field is filled only if the ‘State Autofill’ option is enbaled, do they ask that for the US or for other countries? Does it work when the plugin is disabled?

  6. Hello,
    Would love to use this for my site. But it does not show every city in the Netherlands. How is this possible?

  7. There’s no file named as states.php in plugins folder. I want to set shipping price 200Rs for Karachi a city in Pakistan and 280Rs for other cities of Pakistan. Is it possible to do with this plugin please let me know thanks!

    Regards
    Riaz Ejaz

    1. Dear Riaz,
      Select Pakistan via the plugin settings and press ‘Save Changes’, then create 1 shipping zone with flat rate shipping method (200Rs) and choose Karachi in the Zone regions field, and another shipping zone with flat rate shipping method (280Rs) and choose Pakistan in the Zone regions field, make sure the Karachi shipping zone is above the Pakistan shipping zone.

  8. Hi there,

    I’m a wordpress developer, working actually on a multiple pickup and shipping location e-shop. I have some questions about this awesome Cities Shipping Zone for WooCommerce :

    1. I have removed unnecessary cities in the French city list. In order to reduce load time.
    2. On the checkout and summary page our customers can only choose cities from the drop-down list, but we also have some customers from outside the zone come to us to pick up the order.
    3. So could you add for example « 0 – other cities » on the top of the drop-down list and when the customer choose this option the dropdown transform to text input for customers to enter the city name manually.

    I think this option could be done with a little more conditional logic (if…else), and lots of users need to this in order to make invoice with the right city name of users.

    Thank you for the reply and help.

    1. Hi Kun, please see the ‘How to let the customer to select a city which is not displayed’ section in the docs, full instructions were sent to you by Email

    1. Hi Jose, please try to add this into your theme’s functions.php file:
      add_filter( 'woocommerce_get_country_locale', 'csz_modify_city_label', 9999 );
      function csz_modify_city_label( $locale ) {
      $locale['PE']['state']['label'] = __( 'Distrito' );
      return $locale;
      }

  9. Hi, thanks for this plugin, it’s great.
    I have only one issue, in dropdown city list, either in cart and checkout page, it don’t find all cities in Varese province (all under ‘VA’ in IT.php).
    Thanks in advance.

      1. Hi, a customer reported me “Castelveccana” but also tryng with “Varese” doesn’t work, it seem that every city in the list of this province are not found.
        I’ve checked only “Autofill the state in orders based on the selected city “

  10. Hi,

    I was trying to use your “Cities Shipping Zones for WooCommerce” plugin. However, the country I am trying to use this plugin is not supported. I would to request to add “Malaysia” to the supported countries.

    Thank you in advance.

    1. Hi Tina,
      Bingerville is considered as part of Abidjan, you can use the code from the docs in order to split Abidjan into its sub-prefectures (Abobo, Yopougon and so)

  11. Thank you so much for making this plugin

    I tried to use the given snippet to display only certain cities but it gives me an error when I try to add the PHP code to my child theme.
    is there something I am doing wrong?

    here is my code :
    add_filter( ‘csz_cities’, ‘csz_set_cities’ );
    function csz_set_cities( $states ) {
    $country = ‘NG’;
    $cities = [ ‘NGLASU’, ‘NGLASH, ‘NGLAOI’, ‘NGLAOJ’, ‘NGLAMU’, ‘NGLALM’, ‘NGLALI’, ‘NGLAKO’, ‘NGLAID’, ‘NGLAIJ’, ‘NGLAII’, ‘NGLAIL’, ‘NGLAEO’, ‘NGLAEP’, ‘NGLABA’, ‘NGLAAP’, ‘NGLAAO’, ‘NGLAAL’, ‘NGLAAI’, ‘NGLAAG’ ];
    $new_states = [];
    foreach ( $cities as $city ) {
    if ( isset( $states[ $country ][ $city ] ) ) {
    $new_states[ $city ] = $states[ $country ][ $city ];
    }
    }
    $states[ $country ] = $new_states;
    return $states;
    }

    thanks in advance

    1. Hi Osaze,
      In order to display only certain cities you can select those cities inside some shipping zone (via WooCommerce shipping settings) and then enable the ‘Selling Locations’ option (via the Cities plugin settings)

  12. Hello, I love your plugin and it is working for me but my only concern is how to integrate both the city and state as an option. For example, instead of totally eliminating New York in the options when choosing Bronx County, it shows New York as the State and Bronx as one of the cities in the dropdown lists.

    Please how to configure this? Thanks

  13. Hi, I would like to allow my website to support listing of States before I select my Cities. Kindly explain how to achieve this.

    Also, I discovered that the Cities enumerated for Nigerian State are actually Local Government Areas, while I would like those LGAs to be further broken down into Towns and districts within. I have created a list of these Towns and districts myself and would love to incorporate into your plugin.

    How do I achieve that?

  14. Hi, Once I select my Shipping destination from the list, the checkout does not auto refresh to display Shipping Rates options. Neither does it updates when Shipping destination is changed.

    What could be the Problem?

  15. Hello. The main cities of Senegal are not displayed in the plugin. There are only neighbourhoods in the zones. Can you help me by adding the regions this time? Please

  16. Hello, Good Plugin. Though, there are some cities missing under the Zone region. Please can we expand the list ourselves? If yes, in what files should we do this? Also, can we allow the customer to select a city which is not displayed?

    Thank you.

      1. Please is it possible to set a flat rate to the rest of states within a country. Mind you, I have set the shipping rate for cities in the state the store is located. This takes a lot of time. Now, I want to set a fixed rate for the rest of the state. Please I don’t want to start selecting the cities one after the other. Thank you.

        1. Hi, you can create another shipping zone and select ‘Nigeria’ in the Zone regions field, it will apply on all the cities which were not selected in the other shipping zone. Make sure that the cities shipping zones is appear above the country shipping zone.

  17. My store only delivers in Canada. I want the Free shipping method in 4 cities there which are as follows:
    Cobourg
    Port Hope
    Grafton
    Baltimore

    In all other Cities of Canada, I want Flat rate shipping of $15.

    Can I or how do I set this up?

    1. Hi Jad,
      You can create shipping zone and select in the Zone regions field: Cobourg, Port Hope, Hamilton (which Baltimore is part of), Alnwick/Haldimand (which Grafton is part of) and add the free shipping method to it.
      Create another shipping zone and select ‘Canada’ in the Zone regions field and add the flat rate shipping method.
      Make sure the cities shipping zone appears above the Canada shipping zone.

  18. Awesome. That worked. In the Cart Totals, it says shipping to CAHAMILTON or CACOBOURG. Can I do some modification to display the names without CA. By default, it said shipping to MB. How do I fix that too.
    https://ibb.co/gy21bzf

    1. Please try to put the code from the ‘How to fix the display of the address in the shipping calculator?’ section into your theme’s functions.php

  19. Hi,

    I wanted to try this plugin as it looks promising but I am new to eCommerce and I just want to know if you have a step by step guide on how to use this for beginners. Setting this plugin and what needs to be done on the woocommerce part.

    Thanks

    1. Hi,
      In the plugin settings (Dashboard => WooCommerce => Settings => Cities Shipping Zones) select your country in the first field and press the ‘Save Changes’ button.
      In WooCommerce shipping settings (Dashboard => WooCommerce => Settings => Shipping) edit/create a shipping zone, select some cities in the ‘Zone regions’ field, and add to it a shipping method with the desired price for the cities you have selected.

    1. People from Etobicoke should select Toronto in the city field and can write Etobicoke in the address field. Although it’s possible to modify the name of one of the other cities into ‘Etobicoke’ it’s not recommended.

  20. Hello, I am using the plugin for Perú but is missing one department (Piura) and in Lima a city called “magdalena vieja” is now “pueblo libre”.
    How can I add or modify the cities names?

    1. Hi Cesar,
      Please redownload the plugin, set your store address (WooCommerce General settings), and add this into your theme’s functions.php file:
      add_filter( 'csz_cities', 'csz_modify_cities' );
      function csz_modify_cities( $cities ) {
      $country = 'PE';
      $city = 'PE150121';
      if ( isset( $cities[ $country ][ $city ] ) ) {
      $cities[ $country ][ $city ] .= ' (Pueblo Libre)';
      }
      return $cities;
      }

  21. Hi there,
    Thank you for this great plugin, it works great! However, when activated, everything works well and the order is created in backend but the checkout page stays on loop. Any idea what that might be ? I’m using Rey Theme

    1. Hi Riadh,
      Please make sure the address of your store is set properly (Dashboard => WooCommerce => Settings => General), what’s the URL of the checkout page?

          1. I asked the theme developer the same question, since I’m still on support. I’ll try disabling the theme and see what happens. I might mention I added some cities in the i18n plugin folder by copy pasting and changing the last digit. Is it what’s causing this to happen ? Do I need to add them like you mentioned in this page in order for the plugin to work ?

          1. Hello back, I fixed the issue. It was mainly a server problem and your plugin had nothing to do with that, haha. However, I have a question : Can I display the regions dropdown other than Alphabetically ? And please delete the comments with my staging website on them. Thank you

        1. You can redownload the plugin and use the code from the docs:
          “How to move some states to the top of the dropdown?”
          Update the keys in $first_keys var, for example:
          $first_keys = [ ‘MA07’, ‘MA09’, ‘MA04’ ];

  22. Hey I would like to replace the municipalities with the cities for Pakistan country. Can you please help me with that? I have a list of cities and states updated and I would like to add that list to the plugin. Can you let me know if I can use a custom file for a country just for my website? Adding a whole list and removing the other cities from the plugin individually would take a lot of time. I need help regarding this.

    1. You can modify your cities or municipalities by accessing this folder

      \wp-content\plugins\cities-shipping-zones-for-woocommerce\i18n\cities
      Open your country php file eg DE.php for Germany, modify the content and save it

  23. Hello how can I integrate other shipping options (eg UPS, DHL) to handle shipping method to other countries (International Shipping)
    Because creating shipping price for each city in the world is cumbersome

  24. after installing the plugin every thing is fine. BUT the “add to cart” and quantity increase decrease in product single page stop working.
    do you have any idea?!

    1. Hi Mohamed,
      After you have selected Morocco via the plugin settings, go to shipping zone edit screen (Dashboard => WooCommerce => Settings => Shipping) and select the cities in the Zone regions field.

        1. Aparece algún error? Colombia debe seleccionarse en el primer campo de la configuración. las ubicaciones deben aparecer en la configuración de envío de woocommerce.

  25. Please I just installed your plugin. I intend to use the city dropdown for the shipping zone which works. but i keep getting this error after saving changes “Undefined Array key /home/mrtoolsc/public_html/wp-content/plugins/cities-shipping-zones-for-woocommerce/cities-shipping-zones-for-woocommerce.php on line 769” I use the country only Nigeria

    Please What can i do, i get this error on my website and my ecommerce dashboard

      1. It is still the same thing, i still get the errors and even on the checkout page
        it also writes this
        “please note, your country is set to municipaities and not cities”

  26. Hi Condless, okay, when i disabled the selling location, it cleared the error on the main website. but on my dashboard, i notice i have to input states in different shipping zone before the error clears off one after the other.

    and please how i select a whole state as a shipping zone, as in removing cities in some state.
    thank you. I await your feedback

    1. Try using the Bulk Select tool (in the plugin settings), you can insert a state name/code- then all its cities will be inserted automatically into the selected shipping zone.

  27. For South africa – Limpopo there are missing cities which i want them to be added “Giyani” and “Malamulele

  28. hi, i use this plugin and works fantastic, but need a help.

    In order details and email my “billing_state” is for example “cl451”, but need the “name”, note the code.

    woocommerce_formatted_address_replacements maybe work, but idont know how implement it, maybe you can give me an example.

    Thank you

          1. But idont need country field, need only state/cities. I need help with this:

            “Why the state code and not the state name appears in the order details in the first order email confirmation and in the my account section while using the State Autofill option on countries with WooCommerce built-in states list?
            You can use the woocommerce_formatted_address_replacements filter to fix it.”

            Need state/cities name, not the code in order

          2. The country field must be enabled via the plugin, you can hide it using the CSS:
            #billing_country_field {
            display: none;
            }

  29. Hi, Nice plugin. However when this is activated, it totally disable states why. I want to be able to use states too for my shipping and combine with with cities

  30. Hi Condless Team,
    I install your plugin for Morocco and it’s work very well.
    Now i try to put some cities in the top of dropdown in the order page.
    I tried your solution but don’t where an how to put it for positionning like 10 cities in the top of the dropdown.
    Many thanks for your help

    1. Hi,
      The docs was updated to include the code that put some cities in the top of dropdown, update the code as follow:
      $country = 'MA';
      $first_keys = [ 'MA042810105', 'MA042810301' ]; // the codes of the cities which should be at the top

      1. Hi
        Thanks for your quick answer but where do I put this Code; in the function.php of in the MA.php ? I’m lost
        Thanks for your answer

    1. Hi,
      You can set the location of the store and select ‘Shop Base’ in the Default Customer Address option (WooCommerce General Settings).

      1. Just the send the email. But all I am looking for is to add Guatemala like Ukraine or other request.

  31. Hello,

    Could You please Add Oman to the Coutnry List you support, i really love how your plugin works,

    Thanks in Advance

  32. Hello ,
    I am trying to make a flat rate of 9 riyal for only one place in saudi arabia & 35 Riyal Flat Rate for rest of country
    Can You Help Me My Friend ?

    1. Hi Muhammad,
      Please create 2 shipping zones, 1 for Saudi Arabia and 1 for the special city (drag it to be on the top of the shipping zones list).

    1. Try using the Bulk Select tool (in the plugin settings), you can insert a state name/code- then all its cities will be inserted automatically into the selected shipping zone.

  33. Thanks for the awesome plugin!

    I noticed UAE doesn’t have full list of cities / states. For that, I have compiled full UAE list, how to add it?

    TIA

  34. Hello,

    I would like to use this but I need Mexico on there. Also any chance of making options like just showing certain cities part of the plugin GUI? Thanks!

Leave a Reply to Sheneika Cancel reply

Your email address will not be published. Required fields are marked *