country list / county(state) list

  • simon
    simon
    Newbie 52 points
    August 12, 2016 at 9:10 am

    Morning all – well it’s morning in the UK anyway 😉

    I’ve got a little issue with the drop down lists in the address part of checkout.

    I’m only shipping to the UK so wanted to remove all other countries (that’s done)
    I also, initially, wanted to remove the states part completely. I was having Afghanistan states appearing in the list.

    So I then chopped out ALL states from all countries apart from the UK. Now although that stopped the Afghan states etc the box now doesn’t even show the UK states.

    What else did I do? Well I changed some text in the language file – as per screen grab. Would that have made a difference? Screen grab doesn’t show the empty states list, but it’s empty for sure.

    Any ideas?

    Of course – I can change the language file to “Not Required” but that seems like a messy hack to me – and not a great UX.

    The only thing I noticed in the code (class-search.php) is that the UK is referred to as GB. I assume that’s correct though as the drop down worked before I chopped out the countries. Here’s the first part of MY class-search.php file.

    <?php

    $GLOBALS[‘core_country_list’] = array(‘GB’ => ‘United Kingdom’);

    $GLOBALS[‘core_state_list’] = array(

    ‘GB’ => ‘England|Northern Ireland|Scotland|Wales’,
    //’GB’ => ‘Aberdeenshire|Alderney|Angus|Antrim|Argyll|Armagh|Avon|Ayrshire|Banffshire|Bedfordshire|Berkshire|Berwickshire|Blaenau Gwent|Borders|Bridgend|Buckinghamshire|Bute|Caerphilly|Caithness|Cambridgeshire|Cardiff|Carmarthenshire|Central|Ceredigion|Cheshire|Clackmannanshire|Cleveland|Clwyd|Co. Antrim|Co. Armagh|Co. Derry|Co. Down|Co. Fermanagh|Co. Tyrone|Conwy|Cornwall|Cumberland|Cumbria|Denbighshire|Derbyshire|Derry|Devon|Dorset|Down|Dumfries & Galloway|Dumfriesshire|Dunbartonshire|Durham|Dyfed|East Lothian|East Sussex|Essex|Fermanagh|Fife|Flintshire|Gloucestershire|Grampian|Greater London|Greater Manchester|Guernsey|Gwent|Gwynedd|Hampshire|Hereford & Worcester|Herefordshire|Hertfordshire|Highland|Humberside|Huntingdonshire|Inverness|Isle Of Man|Isle of Anglesey|Isle of Wight|Jersey|Kent|Kincardineshire|Kinross-shire|Kirkcudbrightshire|Lanarkshire|Lancashire|Leicestershire|Lincolnshire|Lothian|Merseyside|Merthyr Tydfil|Mid Glamorgan|Middlesex|Midlothian|Monmouthshire|Moray|Nairnshire|Neath Port Talbot|Newport|Norfolk|North Yorkshire|Northamptonshire|Northumberland|Nottinghamshire|Orkney|Oxfordshire|Peebleshire|Pembrokeshire|Perthshire|Powys|Renfrewshire|Rhondda Cynon Taff|Ross & Cromarty|Roxburghshire|Rutland|Scotland|Selkirkshire|Shetland|Shropshire|Somerset|South Glamorgan|South Yorkshire|Staffordshire|Stirlingshire|Strathclyde|Suffolk|Surrey|Sussex|Sutherland|Swansea|Tayside|Torfaen|Tyne & Wear|Tyne and Wear|Tyrone|Vale of Glamorgan|Wales|Warwickshire|West Glamorgan|West Lothian|West Midlands|West Riding|West Sussex|West Yorkshire|Western Isles|Westmoorland|Westmorland|Wigtownshire|Wiltshire|Worcestershire|Wrexham|Yorkshire’,

    );

    Any help would be great, thanks.

    Attachments:
    You must be logged in to view attached files.

  • Josh
    Super Guru 13,875 points
    August 12, 2016 at 2:32 pm

    Hello Simon,
    Replace the file class_search.php with the attached file (unzip first)

    Attachments:
    You must be logged in to view attached files.
  • simon
    simon
    Newbie 52 points
    August 12, 2016 at 3:28 pm

    Thanks for that Josh.

    Doesn’t seem to have made any difference, though.

    Seems to be the same as the file I have – apart from there’s a bit of rem’ed out stuff not in there.

    Could this be to do with the translation file?

    Weird.

    Simon


  • Josh
    Super Guru 13,875 points
    August 12, 2016 at 3:40 pm

    Please clear your browser cache and disable any caching plugin active

  • simon
    simon
    Newbie 52 points
    August 12, 2016 at 4:39 pm

    Tried it on a different browser and no difference.

    What are the changes to the file?

    Simon

  • simon
    simon
    Newbie 52 points
    August 12, 2016 at 4:47 pm

    Just to add – moved to 8.9.4 just now and the file went back ie all the countries.

    So this being a core file I guess it was updated with the, err, update.

    Interestingly enough, though, the states/counties were still missing after the update. I’m guessing that there has to be an issue with the translation file now? That’s really the only thing I can think of.

    Having “state” is the equivalent in the UK of using the words cheque, pavement, car boot (essentially anything French based) in America 😉 ie you never ever ever do it – it winds people up.

    So perhaps I’ll have to stick with the drop down box with no comments? – unless there is some sneaky css to remove it?

    Simon


  • Josh
    Super Guru 13,875 points
    August 12, 2016 at 4:53 pm

    Please open the file I attached above to see the changes I made you can then do the same in your file.I just remove all countries and states apart from UK and seems to be working correctly on my side

  • simon
    simon
    Newbie 52 points
    August 12, 2016 at 5:02 pm

    Yeah, I think that’s basically what I did.

    If you change the translation file to something else – in my case it’s “County (or leave blank)” Does it still work on your system?

    If it does then there must be something else that’s causing the issue. If not then I guess it proves that the translation file cannot be changed.

    Regards.

    Simon


  • Josh
    Super Guru 13,875 points
    August 12, 2016 at 5:54 pm

    Am not referring to the Language file.The file above (class_search.php) is located in your theme files >framework >class
    Am doing this on a clean version 8.9.4 of the theme with no other files edited

    Attachments:
    You must be logged in to view attached files.
  • simon
    simon
    Newbie 52 points
    August 12, 2016 at 7:45 pm

    Hey Josh,

    Thanks for the update.

    What I meant was – if you make a change to the translations file – does this still work?

    I’ve uploaded your file to the /framework directory and replace the exiting file (although it does seem the same as the file I created myself). Just wondering if a change to the translation will stop this working for you?

    Also – the screen grab you attached – that’s for the users/members area isn’t it. I’m talking about the checkout area (unless I’m being blind – which is possible). 😉

    Simon

  • simon
    simon
    Newbie 52 points
    August 13, 2016 at 12:17 pm

    Ok – bit more info’ on this.

    I setup a brand new site. Used the latest 8.9.4 update.

    No changes made after install – apart from to activate “guest checkout”. I have not added in a payment gateway or anything – I’m only interested in testing this country and state list problem.

    The theme works as it should ie all countries – afghanistan at the top. All of the states are there for the countries too.

    I replace the class-search.php file in the wp-content/themes/ST/framework/class directory.

    The United Kingdom is the only country in the list, but no states are included. So I have to assume that there is something not working correctly here.

    What do you think Josh? I have no idea why this file seems to be working on your system. You can see this site at https://z81.co.uk

  • simon
    simon
    Newbie 52 points
    August 13, 2016 at 2:43 pm

    Ok – so on I go 😉

    Fixed (sort of).

    From what I can see – after some testing…

    There needs to be TWO elements in the core_state_list array.

    So this doesn’t work;

    $GLOBALS[‘core_country_list’] = array( ‘GB’ => ‘United Kingdom’);

    $GLOBALS[‘core_state_list’] = array(

    ‘GB’ => ‘Aberdeenshire|Alderney|Angus|Antrim|Argyll|Armagh|Avon|Ayrshire|Banffshire|Bedfordshire|Berkshire|Berwickshire|Blaenau Gwent|Borders|Bridgend|Buckinghamshire|Bute|Caerphilly|Caithness|Cambridgeshire|Cardiff|Carmarthenshire|Central|Ceredigion|Cheshire|Clackmannanshire|Cleveland|Clwyd|Co. Antrim|Co. Armagh|Co. Derry|Co. Down|Co. Fermanagh|Co. Tyrone|Conwy|Cornwall|Cumberland|Cumbria|Denbighshire|Derbyshire|Derry|Devon|Dorset|Down|Dumfries & Galloway|Dumfriesshire|Dunbartonshire|Durham|Dyfed|East Lothian|East Sussex|Essex|Fermanagh|Fife|Flintshire|Gloucestershire|Grampian|Greater London|Greater Manchester|Guernsey|Gwent|Gwynedd|Hampshire|Hereford & Worcester|Herefordshire|Hertfordshire|Highland|Humberside|Huntingdonshire|Inverness|Isle Of Man|Isle of Anglesey|Isle of Wight|Jersey|Kent|Kincardineshire|Kinross-shire|Kirkcudbrightshire|Lanarkshire|Lancashire|Leicestershire|Lincolnshire|Lothian|Merseyside|Merthyr Tydfil|Mid Glamorgan|Middlesex|Midlothian|Monmouthshire|Moray|Nairnshire|Neath Port Talbot|Newport|Norfolk|North Yorkshire|Northamptonshire|Northumberland|Nottinghamshire|Orkney|Oxfordshire|Peebleshire|Pembrokeshire|Perthshire|Powys|Renfrewshire|Rhondda Cynon Taff|Ross & Cromarty|Roxburghshire|Rutland|Scotland|Selkirkshire|Shetland|Shropshire|Somerset|South Glamorgan|South Yorkshire|Staffordshire|Stirlingshire|Strathclyde|Suffolk|Surrey|Sussex|Sutherland|Swansea|Tayside|Torfaen|Tyne & Wear|Tyne and Wear|Tyrone|Vale of Glamorgan|Wales|Warwickshire|West Glamorgan|West Lothian|West Midlands|West Riding|West Sussex|West Yorkshire|Western Isles|Westmoorland|Westmorland|Wigtownshire|Wiltshire|Worcestershire|Wrexham|Yorkshire’,

    But this does;

    $GLOBALS[‘core_country_list’] = array( ‘GB’ => ‘United Kingdom’);

    $GLOBALS[‘core_state_list’] = array(

    ‘GB’ => ‘Aberdeenshire|Alderney|Angus|Antrim|Argyll|Armagh|Avon|Ayrshire|Banffshire|Bedfordshire|Berkshire|Berwickshire|Blaenau Gwent|Borders|Bridgend|Buckinghamshire|Bute|Caerphilly|Caithness|Cambridgeshire|Cardiff|Carmarthenshire|Central|Ceredigion|Cheshire|Clackmannanshire|Cleveland|Clwyd|Co. Antrim|Co. Armagh|Co. Derry|Co. Down|Co. Fermanagh|Co. Tyrone|Conwy|Cornwall|Cumberland|Cumbria|Denbighshire|Derbyshire|Derry|Devon|Dorset|Down|Dumfries & Galloway|Dumfriesshire|Dunbartonshire|Durham|Dyfed|East Lothian|East Sussex|Essex|Fermanagh|Fife|Flintshire|Gloucestershire|Grampian|Greater London|Greater Manchester|Guernsey|Gwent|Gwynedd|Hampshire|Hereford & Worcester|Herefordshire|Hertfordshire|Highland|Humberside|Huntingdonshire|Inverness|Isle Of Man|Isle of Anglesey|Isle of Wight|Jersey|Kent|Kincardineshire|Kinross-shire|Kirkcudbrightshire|Lanarkshire|Lancashire|Leicestershire|Lincolnshire|Lothian|Merseyside|Merthyr Tydfil|Mid Glamorgan|Middlesex|Midlothian|Monmouthshire|Moray|Nairnshire|Neath Port Talbot|Newport|Norfolk|North Yorkshire|Northamptonshire|Northumberland|Nottinghamshire|Orkney|Oxfordshire|Peebleshire|Pembrokeshire|Perthshire|Powys|Renfrewshire|Rhondda Cynon Taff|Ross & Cromarty|Roxburghshire|Rutland|Scotland|Selkirkshire|Shetland|Shropshire|Somerset|South Glamorgan|South Yorkshire|Staffordshire|Stirlingshire|Strathclyde|Suffolk|Surrey|Sussex|Sutherland|Swansea|Tayside|Torfaen|Tyne & Wear|Tyne and Wear|Tyrone|Vale of Glamorgan|Wales|Warwickshire|West Glamorgan|West Lothian|West Midlands|West Riding|West Sussex|West Yorkshire|Western Isles|Westmoorland|Westmorland|Wigtownshire|Wiltshire|Worcestershire|Wrexham|Yorkshire’,
    ‘DE’ => ”,

    YOu’ll see, right at the very bottom of the bit that DOES WORK, I added in;

    ‘DE’ => ”,

    I’m not skilled enough to know why this works, just that it does 😉

    Now I have my age old issue with the actual contents of that array. Cities like Manchester, Bristol and London are NOT in counties – so any buyers looking for the correct entry will not be able to complete the form. I’ll have to find a list of cities that are affected and add them in manually ;-( but hey ho, go tthe thing to work.

    No idea why yours worked without that extra line Josh? Maybe it’s just a spare line that needs adding? Maybe my text editor was creating an issue? Although I did just drag and drop your file right in via FTP initially. Weird huh? Any ideas?

    Simon

Viewing 12 posts - 1 through 12 (of 12 total)

New Business Themes for WordPress 2020

Start your new website today!

View Business Themes