Currently there is no UI to remove some US states from shipping and billing country list at checkout. It will be nice to have this feature added to commerce module.

Comments

amateescu’s picture

Project: Commerce Core » Address Field
Version: 7.x-1.2 » 7.x-1.x-dev
Component: Checkout » User interface

Moving to the right project.

rszrama’s picture

Status: Active » Closed (duplicate)
Issue tags: +pluggable regions

Marking this a duplicate of #1829900: [meta] Address Field 2.x needs pluggable administrative areas and an actual API. In the meantime, you just have to use hook_form_alter().

philsward’s picture

This page came up first when searching for drupal commerce addressfield hide state, so I'll leave this here...

You can "hide" the states from checkout using CSS, display:none; It's not ideal, but it's better than offering products to folks in all of the outlying United States locations when there's no easy way to actually offer cost-effective shipping to those locations...

Here's a template of CSS to get you started:

/* hide the following states from the checkout shipping profile
 * no shipping available to these locations */

.customer_profile_shipping select option[value="AK"],
.customer_profile_shipping select option[value="HI"],
.customer_profile_shipping select option[value="AA"],
.customer_profile_shipping select option[value="AE"],
.customer_profile_shipping select option[value="AP"],
.customer_profile_shipping select option[value="AS"],
.customer_profile_shipping select option[value="FM"],
.customer_profile_shipping select option[value="GU"],
.customer_profile_shipping select option[value="MH"],
.customer_profile_shipping select option[value="MP"],
.customer_profile_shipping select option[value="PW"],
.customer_profile_shipping select option[value="PR"],
.customer_profile_shipping select option[value="VI"],
.customer_profile_shipping select option[value=" "]
{display: none;}

NOTE: If you're using the chosen module, go add the following to the "enable area" of chosen, to disable it on the checkout forms:

(Yes, this is counter intuitive)

select:visible, select.state:not
nitheesh’s picture

Issue summary: View changes

A better solution is to do a hook_addressfield_administrative_areas_alter() and then restrict the administrative areas keyed by the country.

/**
 * Implements hook_addressfield_administrative_areas_alter()
 */
function custom_module_addressfield_administrative_areas_alter(&$administrative_areas) {
  // This will restrict the states to Alabama and Arizona for US.
  $administrative_areas['US'] = array(
     'AL' => t('Alabama'),
     'AZ' => t('Arizona'),
  );
}