6 replies [Last post]
icymetal's picture
Offline
Joined: 06/19/2009
Juice: 24

I am working on the final phase of a site, intended to sell just a couple of products (to begin with). The products' cost is low and it would make no sense for buyers in Alaska, Hawaii and other territories to pay shipping. For example. A product that costs $20 will ship for about $10 in the 48 states (size doesn't fit in USPS' flat rate boxes) and would cost $30+ shipping to the states and territories mentioned above.

How can I set the list of states in the US to include only the 48 contiguous states? I prefer not to eliminate the others since I may be able to come up later with products that will make sense shipping there - but this would be a longer term issue.

Also, do you know of a more cost effective shipping method for products size of 23" x 23" x 1.5" that weighs about 2.5lb? I would like to reduce costs for my customers.

Thanks for your assistance,
Benny

icymetal's picture
Offline
Joined: 06/19/2009
Juice: 24
Re: Limit US States list to the 48 contiguous

OK - I got it. If anyone have the same need here it is.

In filesyste:
Go to .../all/modules/ubercart/store/countries and modify the "united_states_840_1.cif file. Backup this file since you may need it later. Open the file with a text editor and delete all the lines that you don't want to appear in the States list. Save the file with the original name.

In Drupal:
Go to "Administr/Store Administration/Configuration/Country Settings" and select the Edit tab. If you already have the United States there, remove it. Then, select from the list "united_states_840_1.cif" and press the Import button. You can now check the list of states in your Checkout form.

Hope it helps.

jblank's picture
Offline
Joined: 08/25/2008
Juice: 56
Re: Re: Limit US States list to the 48 contiguous

Does this effect the shipping states only or both shipping and billing? I have a situation where we can only ship to certain states but we can accept purchases from any state.

Thanks.

scorrales's picture
Offline
Joined: 02/19/2009
Juice: 29
Re: Re: Re: Limit US States list to the 48 contiguous

To answer this question, and provide a warning for other users, this will affect both billing and shipping. If you have existing orders, modifying the country list via this method will trash the data on your previous orders. That is, instead of seeing a line like "New York, NY", you'll see "New York, N/A".

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 229
icymetal FTW

This is great, thank you for posting your solution!

scorrales's picture
Offline
Joined: 02/19/2009
Juice: 29
Re: Limit US States list to the 48 contiguous

If you have an existing site with orders or simply don't want to mess modifying a file and then re-importing the country settings, simply edit the uc_zones table in the database and delete the rows you don't want to use.

Ubercart uses the same table to generate its billing and shipping state dropdowns so pulling a state from this table will affect both.

NOTE - this is really the best way I can find to modify this list of states. If you have an existing site with orders and wanted to add back the states that you removed, adding them via the database will be your best solution. Re-importing them via the file/web method described in another post will reset your zone ids and trash the data relating to states on all existing orders.

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 229
Re: Re: Limit US States list to the 48 contiguous

Thanks for your update, very helpful.

I'm currently using JavaScript to achieve the desired results. I throw a script such as this in page.tpl.php just before $closure, where the remove(1) represents the number of the option in the form dropdown:

<?php if($_GET['q'] == "cart/checkout") { ?>
<script type="text/javascript">
document.getElementById('edit-panes-delivery-delivery-zone').remove(1);
document.getElementById('edit-panes-delivery-delivery-zone').remove(2);
</script>
<?php } ?>

And this code snippet just after the $messages block in page.tpl.php for the JavaScript-disabled user, where the bad_states is an array of the id #'s of the states:

<?php
if ($_GET['q'] == 'cart/checkout' || $_GET['q'] == 'cart/checkout/review') {
   
$bad_states = array(150,151);
    if(
in_array($_POST['panes']['delivery']['delivery_zone'], $bad_states)) {
        echo
'<div class="messages error">We cannot ship to the delivery state selected! ...or whatever you'd like to tell the customer...</div>;                           
    }
}
?>