How to fix the UK counties issue introduced by AliDropship/AliExpress

the_lyall

Active Member
This is an AliDropship specific issue and is related to the main plugin (I don't use any of the add-ons).

If you select the United Kingdom as the delivery country, the list of 'counties' provided are not actually UK counties but Countries and Overseas UK Territories. This is because the plugin makes your site match AliExpress, and AliExpress is wrong.

For example the below shows the list of available 'counties' after selecting 'United Kingdom' as the country:

1593779789337.png

There are two easy steps to fixing this:
  1. Install the free plugin WooCommerce Locations Pack which adds all the correct counties for UK, France and some others.
  2. Add the snippet below to your child theme functions.php to remove the incorrect ones that have been added by AliDropship
PHP:
add_filter( 'woocommerce_states', 'custom_uk_states', 10, 1 );
function custom_uk_states( $states ) {
    $non_allowed_uk_states = array( 'England', 'Scotland', 'Wales', 'Other', 'Isle of Man', 'Anguilla', 'Bermuda', 'British Indian Ocean Territory', 'British Virgin Islands', 'Cayman Islands', 'Falkland Islands', 'Gibraltar', 'Montserrat', 'Northern Ireland', 'Pitcairn Islands', 'South Georgia & South Sandwich Islands', 'St Helena, Ascension, Tristan da Cunha', 'Turks and Caicos Islands', 'Guernsey', 'Jersey');

    // Loop through your non allowed counties and remove them
    foreach( $non_allowed_uk_states as $state_code ) {
        if( isset($states['GB'][$state_code]) )
            unset( $states['GB'][$state_code] );
    }
    return $states;
}

The end result is as below, which is much better and much more logical for UK customers:

1593780125481.png

You might wonder why I bothered with this, but if you're in the UK and regularly shop online it is very weird to select 'UK' as the country and then select 'England' as the county instead of 'Bedfordshire' or 'Hertfordshire' or 'London' etc.

This does mean that when placing the orders on AliExpress you'll need to select the relevant country ('England' for example) but it's a small price to pay considering how confusing/off-putting it is for UK customers otherwise. I appreciate it's an extra couple of clicks, but I'd rather make those clicks than not have the order in the first place.
 
Last edited:
Top