Extension that allows you to disable specific region/state for US

Here is little extension called Inchoo_USDisableRegions.
If you have any reason to disable some specific regions from US country, but you don’t want to delete them, this extension will allow you to chose which ones are possible to use for your customer’s addresses.
You can get it here: https://github.com/tomasinchoo/Inchoo_USDisableRegions/tags

Extension is tested only on Magento ver. 1.7.0.2

Keep in mind that this extension is created for purposes of blog article at inchoo.net and as such can only be used as proof of concept.

If you find it helpful in order to learn Magento, that is great, but be careful if you plan to use it in production environment.

So, that’s it, just install extension and go to System->Configuration->General->Enabled Regions and chose ones you would like to use.

Please note that this works only for United States regions.

Let me know if you have any additional questions 😉

You made it all the way down here so you must have enjoyed this post! You may also like:

Experiences of running Magento 1 on PHP 7 Ivan Curdinjakovic
Ivan Curdinjakovic, | 6

Experiences of running Magento 1 on PHP 7

How I learned to stop worrying and love 3rd party modules for Magento Luka Rajcevic
, | 2

How I learned to stop worrying and love 3rd party modules for Magento

Optimize Elasticsearch autocomplete URL for Google Analytics Matej Djakovic
Matej Djakovic, | 2

Optimize Elasticsearch autocomplete URL for Google Analytics

8 comments

  1. Hi,

    I know this post is rather old, however, I recently started experiencing a problem with the extension in 1.9.1. It will intermittently include disabled regions. We haven’t installed any new extensions that interact with the regions. Any ideas on what might be occurring?

    Thanks.

  2. Please replace $allowedCountries[] with $allowedRegions[] in line 41 of
    app\code\community\Inchoo\USDisableRegions\Model\Adminhtml\System\Config\Source\Region.php

    and it will work. It is working fine in CE 1.9.1 as well

  3. Made a couple of modifications to this module and am happy with it now.

    1. For Inchoo_USDisableRegions_Model_Adminhtml_System_Config_Source_Region store the region code as the value, not the name
    2. In Inchoo_USDisableRegions_Model_Resource_Region_Collection, instead of calling addRegionNameFilter(), call addRegionCodeFilter()
    3. In Inchoo_USDisableRegions_Model_Resource_Region_Collection comment out the if isAdmin() stuff, and instead apply the filter as long as ‘adminhtml_system_config_edit’ is not in the list of active layout handles (or we will filter the full state list that we need)
    4. In Inchoo_USDisableRegions_Model_Resource_Region_Collection do not pass $allowedRegions into the region filter, instead, create a proper array of codes/names and pass that in instead.

  4. Inchoo_USDisableRegions_Model_Adminhtml_System_Config_Source_Region

    In the foreach block, the array that is loaded with results is $allowedCountries but it should be $allowedRegions.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.