Vote up!
Vote down!

Only Ship To Certain States

How do you only ship to certain states, such as the lower 48 States? In Ubercart I would just modify the database values, but I wasn't sure if there was an administrative area that allows you to do so in Commerce? If not, I am fine modifying the database... but I couldn't find the correct table. Ubercart it was UC_Zones or something like that.

Any thoughts?

Asked by: BD3
on July 24, 2012

7 Answers

Vote up!
Vote down!

I'm not sure what you're talking about with respect to Ubercart unless you mean there are database administered state restrictions for one of its various shipping plugins. In Commerce, though, you control shipping service availability on a service by service basis using Rules. This means if you define your own flat rates through Commerce Flat Rate, you can add conditions so only certain flat rates appear at certain times (like "Free shipping" only showing up for orders over $100). If you're using a module like Commerce UPS or USPS that define those carriers' various services, then you can put conditions on each service's Rules component that check the state before making the service available.

To restrict the calculation of shipping rates for an entire shipping method like this (e.g. Flat rate, UPS, USPS), each shipping method has a default Rule that you can add conditions to. I think this is what you'll need, and you can use a set of "Order address component comparison" conditions to ensure items aren't shipped to the wrong state. Additionally, you should configure the "Shipping service" checkout pane to not allow checkout to proceed without a valid shipping service being selected.

I'd recommend conditions that check that the country is US and that the state is not AK or HI. That'll be much faster than checking to make sure it is one of the 48 states.

Ryan Szrama
Answer by: Ryan Szrama
Posted: Jul 25, 2012
Vote up!
Vote down!

Is there any solution to this?? we need the user only to choose from two provinces for shipping

Thanks so much

Answer by: drupalin
Posted: Jan 26, 2017
Vote up!
Vote down!

@Ryan, thanks for the post! I was able to do as your instructed and it works out great.

In regards to Ubercart, I would go into the database and change the uc_zones states to 0 and then they wouldn't appear as an option at checkout. But your way for commerce works just great.

Answer by: BD3
Posted: Aug 2, 2012
Vote up!
Vote down!

I tried to restrict the states, but the parameters didn't seem to have a "does not equal" option. How would I restrict AK and HI?

Answer by: Anonymous (not verified)
Posted: Oct 3, 2012


For this you have to add two conditions (one for Alaska and one for Hawaii). Set the operator to equals and the values to HI for one and AK for the other. You will then have to NEGATE the condition.

- BD3 on November 7, 2012
Vote up!
Vote down!

Letting people select the state just to tell them it's not allowed later doesn't make much sense. How can we delete states without hacking ? like in this case: http://www.drupalcommerce.org/questions/8045/what-file-or-table-produces...

Answer by: mv
Posted: Dec 2, 2013


Vote up!
Vote down!

Use AND condition for following:

Order address component comparison
Parameter: Order: [commerce_order], Address: Address, Address component: Country, Value: US

NOT Order address component comparison
Parameter: Order: [commerce_order], Address: Address, Address component: Administrative area (State
Operator: is one of, Value:

Get codes from here: http://www.50states.com/abbreviations.htm

USPS ships at Domestic rate to Armed Forces, so I decided not to include those but your situation might require to add those also.

Answer by: Avi
Posted: Jun 25, 2014
Vote up!
Vote down!

This is a good post so far at all. Really i was looking forward to read about this entry. And all these information are very helpful to me. Thanks for this allocation. :lol:
magic of making up

Answer by: Anonymous (not verified)
Posted: Sep 11, 2012