Restrict shipping to state/region and offer 'request a quote' for orders from outside that state

@pepperclip is right! I dug deeper and figured out how this can be solved. In my case a client needed to be able to ship to all USA states and prevent shipping from Louisiana, Tennessee, and Georgia. This can be achieved using the Pattern input attribute.

There might be a cleaner or simple way to do this, but this is how I achieved it.

Select the input field that you want to define only certain values being allowed for. In my case it was the field to enter the “State”. Then create a new attribute with a name of “pattern” and then paste the below snippet in as the value. The below snippet contains every US state as well as every US state abbreviation in both uppercase and lowercase — except Georgia, Louisiana, and Tennessee. This way when a user enters their state, as long as it matches one of those it will let the field entry be successful, but anything not on that list will not go through.

Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|Florida|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Maine|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming|AL|AK|AZ|AR|CA|CO|CT|DE|FL|HI|ID|IL|IN|IA|KS|KY|ME|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|SD|TX|UT|VT|VA|WA|WV|WI|WY|alabama|alaska|arizona|arkansas|california|colorado|connecticut|delaware|florida|hawaii|idaho|illinois|indiana|iowa|kansas|kentucky|maine|maryland|massachusetts|michigan|minnesota|mississippi|missouri|montana|nebraska|nevada|new hampshire|new jersey|new mexico|new york|north carolina|north dakota|ohio|oklahoma|oregon|pennsylvania|rhode island|south carolina|south dakota|texas|utah|vermont|virginia|washington|west virginia|wisconsin|wyoming|al|ak|az|ar|ca|co|ct|de|fl|hi|id|il|in|ia|ks|ky|me|md|ma|mi|mn|ms|mo|mt|ne|nv|nh|nj|nm|ny|nc|nd|oh|ok|or|pa|ri|sc|sd|tx|ut|vt|va|wa|wv|wi|wy

Lastly, create one more attribute with a name of “title” and your value can be whatever message you want the user to see when they don’t match one of the correct input values. In my case it was “Enter state abbreviation. We do not ship to Tennessee, Louisiana, or Georgia.”

See the screenshot below where this is all setup.

If anyone has a cleaner solution please drop it below – but this is what I have working for now!

I also put together a quick Codepen where you can see this working and see the values.

4 Likes