Zen Cart Logo
Forums / General Questions / State Abbreviations

State Abbreviations

Locked

Views: 3,880

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
12 Aug 2007, 4:44 AM
#1
vs4hire avatar

vs4hire

New Zenner

Join Date:
Nov 2006
Posts:
47
Plugin Contributions:
0

State Abbreviations

I've done a search here for problems with state abbreviations and didn't find an answer, so here goes:

I would like US States & Canadian Provinces to show up in both admin as well as the customer sign up page with their 2 letter abbreviation. Right now they show up as full state names.

I looked in my zones table and noticed that the "Zone Code" is the abbreviation...then I looked to see if it was an option anywhere (ie "Set States to Abbreviations - true/false, etc) and didn't see anything...

What am I missing?

Thanks,
Michelle

12 Aug 2007, 7:29 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: State Abbreviations

This is in the DB and in the admin > localization/taxes > zone definitions > pick one that exists > right box select details > select countries as united states > check the manes in the zones drop down.

I think that you can edit the DB to make these 2 letter abbreviations with out breaking anything but as always make a DB backup before attempting this.

Maybe another will chime in as to if this will break any other functions?

12 Aug 2007, 3:10 PM
#3
vs4hire avatar

vs4hire

New Zenner

Join Date:
Nov 2006
Posts:
47
Plugin Contributions:
0

Re: State Abbreviations

I don't necessarily think it has anything to do with actual "Zones" because shipping calculates correctly and I only have NY set up in Zone Definitions (for sales tax - which also works properly).

It's just a matter of display preferences - but I think you're right about somehow changing the database - problem is I WOULD break something! :cool:

Any other ideas??

Thanks!
Michelle

12 Aug 2007, 5:16 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: State Abbreviations

Yes you can name your zone anything but did you follow what I posted? Beecause this leads you to the dropdown with the stored DB state names

12 Aug 2007, 6:04 PM
#5
vs4hire avatar

vs4hire

New Zenner

Join Date:
Nov 2006
Posts:
47
Plugin Contributions:
0

Re: State Abbreviations

I see what you mean - manually edit the database changing "Alabama" to AL

I can't really do that without knowing if it's gonna break the shipping calculation...not sure if shipping NEEDS to have the full state name or if will still work with just the abbreviation.

I suppose I could try it sometime early morning...just afraid to make a big oopsie.

Thanks!
Michelle

P.S. I'll let you know what happens when I get the courage up to try!

12 Aug 2007, 6:07 PM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: State Abbreviations

I suppose I could try it sometime early morning...just afraid to make a big oopsie.
And why I cautioned you to backup the DB before you attempt anything so if it does not work you can just restore from the original

12 Aug 2007, 6:10 PM
#7
vs4hire avatar

vs4hire

New Zenner

Join Date:
Nov 2006
Posts:
47
Plugin Contributions:
0

Re: State Abbreviations

I just tried it with 1 state, and it worked like a charm - had a brainfart that the shipping I use is through USPS (so it uses the zip code I believe).

Thanks for the idea!

Michelle

12 Aug 2007, 6:12 PM
#8
vs4hire avatar

vs4hire

New Zenner

Join Date:
Nov 2006
Posts:
47
Plugin Contributions:
0

Re: State Abbreviations

Next question - would you know how to change the order of the abbreviations?

Such as sending AE (Armed Forces Eurpoe) to the end of the list?

Thanks!
Michelle

12 Aug 2007, 9:16 PM
#9
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: State Abbreviations

I thought these were alpha sorted??

15 Aug 2007, 1:27 PM
#10
vs4hire avatar

vs4hire

New Zenner

Join Date:
Nov 2006
Posts:
47
Plugin Contributions:
0

Re: State Abbreviations

They ARE alpha sorted, which is exactly the problem...

For example, "Armed Forces America" (abbrev AA) is a very uncommon "state"...I would like that to show up at the end of the list rather than being the first one. I would like the ability to control the display order of the abbreviations.

Thanks!
Michelle

15 Aug 2007, 2:41 PM
#11
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: State Abbreviations

VS4Hire:

They ARE alpha sorted, which is exactly the problem...

For example, "Armed Forces America" (abbrev AA) is a very uncommon "state"...I would like that to show up at the end of the list rather than being the first one. I would like the ability to control the display order of the abbreviations.

Thanks!
Michelle
Try putting a space before the " AA" or try a hyphen "-AA"
JOhn ><>

2 Sep 2009, 10:43 PM
#12
fbroz avatar

fbroz

New Zenner

Join Date:
Mar 2008
Posts:
35
Plugin Contributions:
1

Re: State Abbreviations

I ran into a similar issue. I wanted the delivery address on the packing slip to use the state abbreviation instead of the state name since I use it to make the shipping label.

To accomplish this I used the zones table to get the state code:

  $state_abbr = $db->Execute("select zone_code
                          from " . TABLE_ZONES . "
                          where zone_name = '" . $order->delivery['state'] . "'");

then replaced the delivery state (to be used in forming the delivery address) with the state code:

  $order->delivery['state'] = $state_abbr->fields['zone_code']; 

I added those lines after the billing/shipping address check in admin/packingslip.php. The original looked like this:

  if ($order_check->fields['billing_street_address'] != $order_check->fields['delivery_street_address']) {
    $show_customer = 'true';
  }

the new version looks like this:

  if ($order_check->fields['billing_street_address'] != $order_check->fields['delivery_street_address']) {
    $show_customer = 'true';
  }
  // change state abbreviation
  $state_abbr = $db->Execute("select zone_code
                          from " . TABLE_ZONES . "
                          where zone_name = '" . $order->delivery['state'] . "'");
  $order->delivery['state'] = $state_abbr->fields['zone_code'];

I would definitely appreciate any tips to improve this code with regards to "Zen best practices" or general PHP or mysql tips.

I think in the US the state code is preferred by USPS over the full state name, so making this change could possibly improve your delivery times.

6 Dec 2009, 12:33 AM
#13
dgmdan avatar

dgmdan

New Zenner

Join Date:
Feb 2009
Posts:
12
Plugin Contributions:
0

Re: State Abbreviations

fbroz:

I ran into a similar issue. I wanted the delivery address on the packing slip to use the state abbreviation instead of the state name since I use it to make the shipping label.

To accomplish this I used the zones table to get the state code:

Worked for me. I modified your code to also change the billing address:

// change delivery state abbreviation
  $state_abbr = $db->Execute("select zone_code
                          from " . TABLE_ZONES . "
                          where zone_name = '" . $order->delivery['state'] . "'");
  $order->delivery['state'] = $state_abbr->fields['zone_code'];
// change billing state abbreviation
  $state_abbr = $db->Execute("select zone_code
                          from " . TABLE_ZONES . "
                          where zone_name = '" . $order->billing['state'] . "'");
  $order->billing['state'] = $state_abbr->fields['zone_code'];