Learn how to limit shipping to a certain state using the Shopp countries filter. This will be added to your themes functions.php file.

How to Limit Shipping to Certain States using the Shopp Country Zones Filter

How to Limit Shipping to Certain States using the Shopp Country Zones Filter

In this tutorial we’ll go over how to prevent shipping to a certain state or states within the USA. This will be accomplished using the Shopp country zone filter.

An Overview of the Shopp Country Zones Filter

Lets get started by viewing an example of the countries filter for Shopp:

function RemoveSpecificStatesInUSA( $zones ) {
    $zones['US'] = 
        array(
        '01' => 'Alambama',
        '02' => 'Alaska',
        '03' => 'Arizona',
        '04' => 'Arkansas',
        '05' => 'California',
        '06' => 'Colorado',
        '07' => 'Connecticut',
        '08' => 'Delaware',
        '09' => 'District Of Columbia',
        '10' => 'Florida',
        '11' => 'Georgia',
        '12' => 'Hawaii',
        '13' => 'Idaho',
        '14' => 'Illinois',
        '15' => 'Indiana',
        '16' => 'Iowa',
        '17' => 'Kansas',
        '18' => 'Kentucky',
        '19' => 'Louisiana',
        '20' => 'Maine',
        '21' => 'Maryland',
        '22' => 'Massachusetts',
        '23' => 'Michigan',
        '24' => 'Minnesota',
        '25' => 'Mississippi',
        '26' => 'Missouri',
        '27' => 'Montana',
        '28' => 'Nebraska',
        '29' => 'Nevada',
        '30' => 'New Hampshire',
        '31' => 'New Jersey',
        '32' => 'New Mexico',
        '33' => 'New York',
        '34' => 'North Carolina',
        '35' => 'North Dakota',
        '36' => 'Ohio',
        '37' => 'Oklahoma',
        '38' => 'Oregon',
        '39' => 'Pennsylvania',
        '40' => 'Rhode Island',
        '41' => 'South Carolina',
        '42' => 'South Dakota',
        '43' => 'Tennessee',
        '44' => 'Texas',
        '45' => 'Utah',
        '46' => 'Vermont',
        '47' => 'Virginia',
        '48' => 'Washington',
        '49' => 'West Virginia',
        '50' => 'Wisconsin',
        '51' => 'Wyoming'
        );

    return $zones;
}

add_filter('shopp_country_zones', 'RemoveSpecificStatesInUSA');

Note that we have given the function a unique name of “RemoveSpecificStatesInUSA” — additionally the filter also references the name of the function.

The above example enables all 50 states of the United States + the District of Columbia. This is the default option in Shopp.

The country zone filter for Shopp works in the following manner:

  • States that exist in the function are enabled
  • States that are not included in the function are disabled

In the example below, we have removed Alaska and Hawaii from the list:

function RemoveSpecificStatesInUSAAlaskaHawaii ( $zones ) {
    $zones['US'] = 
        array(
        '01' => 'Alabama',
        '03' => 'Arizona',
        '04' => 'Arkansas',
        '05' => 'California',
        '06' => 'Colorado',
        '07' => 'Connecticut',
        '08' => 'Delaware',
        '09' => 'District Of Columbia',
        '10' => 'Florida',
        '11' => 'Georgia',
        '13' => 'Idaho',
        '14' => 'Illinois',
        '15' => 'Indiana',
        '16' => 'Iowa',
        '17' => 'Kansas',
        '18' => 'Kentucky',
        '19' => 'Louisiana',
        '20' => 'Maine',
        '21' => 'Maryland',
        '22' => 'Massachusetts',
        '23' => 'Michigan',
        '24' => 'Minnesota',
        '25' => 'Mississippi',
        '26' => 'Missouri',
        '27' => 'Montana',
        '28' => 'Nebraska',
        '29' => 'Nevada',
        '30' => 'New Hampshire',
        '31' => 'New Jersey',
        '32' => 'New Mexico',
        '33' => 'New York',
        '34' => 'North Carolina',
        '35' => 'North Dakota',
        '36' => 'Ohio',
        '37' => 'Oklahoma',
        '38' => 'Oregon',
        '39' => 'Pennsylvania',
        '40' => 'Rhode Island',
        '41' => 'South Carolina',
        '42' => 'South Dakota',
        '43' => 'Tennessee',
        '44' => 'Texas',
        '45' => 'Utah',
        '46' => 'Vermont',
        '47' => 'Virginia',
        '48' => 'Washington',
        '49' => 'West Virginia',
        '50' => 'Wisconsin',
        '51' => 'Wyoming'
        );

    return $zones;
}

add_filter('shopp_country_zones', 'RemoveSpecificStatesInUSAAlaskaHawaii');

Note that we have once again given our function a unique name.

Lets look at one more example. The example below only has Florida as an option. Therefore all other states would be removed from our shipping options and only Florida would be available as a ship-to state.

function RemoveStatesKeepOnlyFlorida ( $zones ) {
    $zones['US'] = 
        array(
        '10' => 'Florida'
        );

    return $zones;
}

add_filter('shopp_country_zones', 'RemoveStatesKeepOnlyFlorida');

Applying the Shopp Country Zones Filter

The Shopp country zones filter needs to be applied to the functions.php of the active theme.

  1. Open your preferred FTP / SFTP client (FileZilla is a free option; Cyberduck is another choice).
  2. Login to your WordPress root via SFTP or FTP.
  3. Browse to the location of your theme’s functions.php file. This is generally wp-content/themes/yourthemefolder/functions.php. If you are unsure, check with the documentation for your theme.
  4. Open the functions.php file for editing.
  5. Now enter your new filter. Another option is to copy and paste one of the examples mentioned prior and then make edits as needed to remove certain states.
  6. Save changes to the file.

Notes

Limiting shipping to certain states could lead to frustrated customers. We recommend placing several notices on your site letting your customers know about shipping restrictions. An easy option is to add a notice in a widget (since widgets are shown site-wide). You may also want to edit your Shopp content templates to add some notices.

Avatar of Lorenzo Orlando Caum

By

Lorenzo Orlando Caum is the founder of Enzo12 LLC, a consultancy in Tampa, FL. Lorenzo provides consulting services such as a Shopp upgrade service through Shopp 101. He also recommends using managed WordPress hosting with Shopp because a faster site means more sales. You can learn more about Lorenzo, you can follow @lorenzocaum on Twitter or check out his blog.

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.

Skip to toolbar